Visual C++ 2013 gives linker errors when using __inline/inline?

Can anybody tell me what's going wrong here?

I've defined all functions a follows (using a constant for determine __inline/inline/nothing):

1
2
3
#define OPTINLINE __inline
(...)
OPTINLINE double getCurrentClockSpeed(); //Retrieves the current clock speed! 


Project file: http://superfury.heliohost.org/cplusplus/x86EMU.vcxproj

The errors I'm getting for the inlined functions (I've checked the headers: they're identical to the functions in the *.c files, although the paths might differ): http://superfury.heliohost.org/cplusplus/x86EMU.vcxproj
You forgot to post errors. But you do know that inline function definitions should be in header file alongside declarations, do you? They cannot be moved in separate cpp file.
@MiiNiPaa: So I can't declare the inline functions in the headers and the body in the cpp file?

main.c:
1
2
3
4
5
6
#include "types.h" //Above headers

OPTINLINE double getCurrentClockSpeed()
{
return 222.0f; //222MHz
}


Other c file:
1
2
3
4
#include "types.h" //Above headers
(...)
float test = getCurrentClockSpeed();
(...)
No, you cannot. Standard requires for function definition exist in every compilation unit which uses it:
Standard wrote:
7.1.2.4
An inline function shall be defined in every translation unit in which it is odr-used and shall have exactly the same definition in every case
Last edited on
Topic archived. No new replies allowed.