Problems with including header files
Posted on 1998-04-23
I use C++ 5.0 from MS (I don't use any SP) and I'm working without MFC.
I make a header file of a cpp which only consists of functions. When I compile it, it all goes well. When I want to include it in another project, the number and kinds of error messages exceed my wildest dreams.
Like C2143 missing ')' before '=' and C2072 '_itoa ' initialization of a function and C2059 syntax error ')'
When I try different settings, and different function calls (i.e. without radix=10) I get different errors. I think I'm doing something wrong in the compiler settings but I don't know what.
The question is two-ways:
Can anyone tell me how to get rid of the errors mentioned and state me exactly WHICH compiler settings I should use and WHY so I won't have these problems again. I'm always guessing about those things and mostly hope that when I hit "win32 application" in the app wizard, that that will do. Probably not.
Below is the code causing the trouble:
Include file "common.h"
char * _itoaX(int i, int radix=10);
LPTSTR GetCommandLineX(int *argc, char * argv, const int argmax=20);
The file common.cpp (this one compiles correctly, no errors) (The 'X' behind the function names were'nt there before. It should be overloaded functions):
char * _itoaX(int i, int radix)
char * buff=(char *) malloc(64);
return(_itoa(i, buff, radix));
LPTSTR GetCommandLineX(int *argc, char * argv, const int argmax)
char seps=" /-\"\t";
if (lpCmdLine==NULL) return(FALSE);
//strtok(NULL, seps) looks subsequently to the next token of the
//last called variable (lpCmdLine)
#define i *argc
while ((argv[i]=i==0?strtok(lpCmdLine, seps):strtok(NULL, seps))!=NULL&&i<=20)
++i; //i++ won't do here because of the '*' in '*argc'
The main file (in this case without functions. That caused the errors mentioned above):
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )