Asyncronous Function Calls
std::vector&lt;std::thread&gt; asyncCalls;


This creates a global variable (so, you know, don't do that) — and it creates the global variable in every .cpp file that imports this header file. So unless you only have one .cpp file in your project, you're going to get linker errors when you try to link your project.

What you wanted to do was put this variable definition in a .cpp file and put a declaration of it (using extern) in your .hpp file.

Alternatively, as of C++17, you could have made it an inline variable:

inline std::vector&lt;std::thread&gt; asyncCalls;


However, global variables are terrible; don't do anything like this. Maybe what you want is some notion of "thread pool":

class ThreadPool {
    std::vector&lt;std::thread&gt; asyncCalls;
    // ...
};




#define asyncCall asyncCalls.emplace_back // Whenever someone calls asyncCall this constructs a new std::thread which calls their function


This is a preprocessor macro (so, you know, don't do that). What you meant was

class ThreadPool {
    std::vector&lt;std::thread&gt; asyncCalls;

public:
    template&lt;typename... Args&gt;
    void asyncCall(Args&amp;&amp;... args) {
        asyncCalls.emplace_back(std::forward&lt;Args&gt;(args)...);
    }
};




void finishAsync(){ //Call to block until all running asyncronous functions return
while(!asyncCalls.empty()){ //Loop until the vector is empty


Two things:


Please indent your code. Four-space indents would be nice.
Who do you expect to call this function? and how do you know that nobody else is going to be calling emplace_back at the same instant that that guy is calling empty? Looks like you have a huge thread-safety problem here.




#ifdef _GLIBCXX_CHRONO //Include &lt;chrono&gt; before this header for this function


Don't do this. For one thing, your code won't do the right thing on Clang with libc++ (or MSVC, or basically any non-libstdc++ distribution). What you meant was

#include &lt;chrono&gt;


This way, your header includes all the headers it depends on, recursively, and you never have to worry about whether your caller included something else before you or not.



As far as "would this code be a good idea if it worked": a resounding no. Your asyncCall function isn't really doing anything that std::async wouldn't do on its own; and std::async on its own is a bad idea because if you call it too many times you'll eventually run out of threads and start getting "Resource temporarily exhausted" errors. If you're going to be writing programs that use asynchrony as their primary implementation technique, the last thing you want to do is run out of threads. You need to figure out some way to queue up "tasks" without tying up a whole std::thread per (stalled) task.