Can't inline a 1 line void function!

I have this simple function in a file:

1
2
3
4
5
6
7
8
9
generic.cpp

#include <iostream>
#include <string>

inline void clearScreen()
{
    std::cout << std::string( 30, '\n' ) << std::endl;
}


Now when I simply call this, clearScreen();, in main.cpp, I get this:

* warning: inline function 'void clearScreen()' used but never defined [enabled by default]|
* error: undefined reference to `clearScreen()'|

I've also forward declared it in main: inline void clearScreen();. It works fine without the inline keyword, not sure why it doesn't like it though?
Last edited on
I'd think you shouldn't have to forward declare it at all. Just include the entire inline definition in the header; if you put it in a separate source file then it can't be inlined.
Ok, thanks for clearing that up, that worked.

Cheers!
Last edited on
Topic archived. No new replies allowed.