basically i have a header full of function prototypes(util.h) and a cpp file with the functions body
// util.h
#include <ctime>
uint32_t GetTime( );
uint32_t GetTicks( );
// util.cpp
#include <util.h>
uint32_t GetTime( )
{
return GetTicks( ) / 1000;
}
uint32_t GetTicks( )
{
return clock( );
}
// main.cpp
#include <conio.h>
#include <iostream>
#include "util.h"
int main(int argc, char* argv[])
{
uint32_t StartTime = GetTicks( );
//
// some code here
//
std :: cout << GetTicks( ) - StartTime << " milliseconds passed since the program started" << std :: endl;
getch( );
return 0;
}
because i'll use GetTicks( ) and GetTime( ) many times in my code and the function body is really small i'd like to make them inline, but the linker fails if i try to do this
// util.h
#include <ctime>
inline uint32_t GetTime( );
inline uint32_t GetTicks( );
// util.cpp
#include <util.h>
inline uint32_t GetTime( )
{
return GetTicks( ) / 1000;
}
inline uint32_t GetTicks( )
{
return clock( );
}
or this:
// util.h
#include <ctime>
inline uint32_t GetTime( );
inline uint32_t GetTicks( );
// util.cpp
#include <util.h>
uint32_t GetTime( )
{
return GetTicks( ) / 1000;
}
uint32_t GetTicks( )
{
return clock( );
}
or this:
// util.h
#include <ctime>
uint32_t GetTime( );
uint32_t GetTicks( );
// util.cpp
#include <util.h>
inline uint32_t GetTime( )
{
return GetTicks( ) / 1000;
}
inline uint32_t GetTicks( )
{
return clock( );
}
any of these 3 i try, the linker fails telling me there are 2 prototypes not resolved
i appreciate any help