If you are using the "fastcall" linking option under Windows it will causeI copied the function from
http://f11.parsimony.net/forum16635/messages/61760.htm
I tried to compile it with no success.
I get one warning and 4 errors inspite of starting with 2 includes
Here is the code(defs.h and data.h are files that I include in every
file of my program and they include the global varaibles of the program.
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && fpLog != (FILE *)NULL)
{
vfprintf(fpLog, szFormat, vargs);
fflush(fpLog);
}
va_end(vargs);
}
the warning is
warning C4096: '__cdecl' must be used with '...'
The errors are that g_bLogging and fpLog are not defined.
I guess that the error means that I need to have global varaible for
integer and to use logmovei that is defined as external FILE* in data.h
and as FILE* in data.c instead of using fpLog but I first care about the
first warning.
Now compile is ok but I have problems with building it.Hey Uri,
Some answers interspersed below.If you are using the "fastcall" linking option under Windows it will causeI copied the function from
http://f11.parsimony.net/forum16635/messages/61760.htm
I tried to compile it with no success.
I get one warning and 4 errors inspite of starting with 2 includes
Here is the code(defs.h and data.h are files that I include in every
file of my program and they include the global varaibles of the program.
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && fpLog != (FILE *)NULL)
{
vfprintf(fpLog, szFormat, vargs);
fflush(fpLog);
}
va_end(vargs);
}
the warning is
warning C4096: '__cdecl' must be used with '...'
The errors are that g_bLogging and fpLog are not defined.
I guess that the error means that I need to have global varaible for
integer and to use logmovei that is defined as external FILE* in data.h
and as FILE* in data.c instead of using fpLog but I first care about the
first warning.
the error you're seeing. Changing the function prototype (and the actual
function) to:
void __cdecl PrintLog(const char *szFormat, ...);
void __cdecl PrintLog(const char *szFormat, ...)
{
etc.
}
should fix things (I should have mentioned this initially). I have this
set up as a define that so that when I compile the program under Linux the
__cdecl is removed by the preprocessor.
As you surmised, you need two global variable to make this work in the
form presented. I think once you get the compiler to recognize the two
globals the remaining errors will likely go away, (if not feel free to
post the *new* errors here
regards,
--tom
Here is the function that I have when both logmovei and g_bLogging are global in data.h and data.cNow compile is ok but I have problems with building it.Hey Uri,
Some answers interspersed below.If you are using the "fastcall" linking option under Windows it will causeI copied the function from
http://f11.parsimony.net/forum16635/messages/61760.htm
I tried to compile it with no success.
I get one warning and 4 errors inspite of starting with 2 includes
Here is the code(defs.h and data.h are files that I include in every
file of my program and they include the global varaibles of the program.
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && fpLog != (FILE *)NULL)
{
vfprintf(fpLog, szFormat, vargs);
fflush(fpLog);
}
va_end(vargs);
}
the warning is
warning C4096: '__cdecl' must be used with '...'
The errors are that g_bLogging and fpLog are not defined.
I guess that the error means that I need to have global varaible for
integer and to use logmovei that is defined as external FILE* in data.h
and as FILE* in data.c instead of using fpLog but I first care about the
first warning.
the error you're seeing. Changing the function prototype (and the actual
function) to:
void __cdecl PrintLog(const char *szFormat, ...);
void __cdecl PrintLog(const char *szFormat, ...)
{
etc.
}
should fix things (I should have mentioned this initially). I have this
set up as a define that so that when I compile the program under Linux the
__cdecl is removed by the preprocessor.
As you surmised, you need two global variable to make this work in the
form presented. I think once you get the compiler to recognize the two
globals the remaining errors will likely go away, (if not feel free to
post the *new* errors here
regards,
--tom
logfunctions.obj : error LNK2001: unresolved external symbol "struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol "int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
Hello Matthias,// printing both to the logfile and to stdout or nul
void PrintLog(FILE *fp, bool bLogging, char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat); vprintf(szFormat, vargs); fflush(stdout);
if (bLogging && fp != (FILE *)NULL) { vfprintf(fp, szFormat, vargs); fflush(fp); }
va_end(vargs);
}
I don't use fastcall, so I don't need __cdecl.
Would fastcall "fasten" my program by 10% or more ?
/Matthias.
Unfortunately, I don't have my code in front of me but I believe what you needHere is the function that I have when both logmovei and g_bLogging areNow compile is ok but I have problems with building it.
logfunctions.obj : error LNK2001: unresolved external symbol
"struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol
"int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
global in data.h and data.c
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void __cdecl PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Uri
Here is the function that I have when both logmovei and g_bLogging are global in data.h and data.cNow compile is ok but I have problems with building it.Hey Uri,
Some answers interspersed below.If you are using the "fastcall" linking option under Windows it will causeI copied the function from
http://f11.parsimony.net/forum16635/messages/61760.htm
I tried to compile it with no success.
I get one warning and 4 errors inspite of starting with 2 includes
Here is the code(defs.h and data.h are files that I include in every
file of my program and they include the global varaibles of the program.
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && fpLog != (FILE *)NULL)
{
vfprintf(fpLog, szFormat, vargs);
fflush(fpLog);
}
va_end(vargs);
}
the warning is
warning C4096: '__cdecl' must be used with '...'
The errors are that g_bLogging and fpLog are not defined.
I guess that the error means that I need to have global varaible for
integer and to use logmovei that is defined as external FILE* in data.h
and as FILE* in data.c instead of using fpLog but I first care about the
first warning.
the error you're seeing. Changing the function prototype (and the actual
function) to:
void __cdecl PrintLog(const char *szFormat, ...);
void __cdecl PrintLog(const char *szFormat, ...)
{
etc.
}
should fix things (I should have mentioned this initially). I have this
set up as a define that so that when I compile the program under Linux the
__cdecl is removed by the preprocessor.
As you surmised, you need two global variable to make this work in the
form presented. I think once you get the compiler to recognize the two
globals the remaining errors will likely go away, (if not feel free to
post the *new* errors here
regards,
--tom
logfunctions.obj : error LNK2001: unresolved external symbol "struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol "int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void __cdecl PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Uri
Thanks to both of you but unfortunately it did not solve the problemUnfortunately, I don't have my code in front of me but I believe what you needHere is the function that I have when both logmovei and g_bLogging areNow compile is ok but I have problems with building it.
logfunctions.obj : error LNK2001: unresolved external symbol
"struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol
"int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
global in data.h and data.c
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void __cdecl PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Uri
to do is define your two globals in the data.c file as:
FILE *logmovei = (FILE *)NULL;
int g_bLogging = 0;
Of course, the syntax could be slightly different (for one thing since these
are globals they will be zeroed out when the program initializes anyway, but
you get the idea).
And define two extern statements in the data.h file.
extern FILE *logmovei;
extern int g_bLogging;
This should hopefully resolve your linker problems.
regards,
--tom
I solved the problemThanks to both of you but unfortunately it did not solve the problemUnfortunately, I don't have my code in front of me but I believe what you needHere is the function that I have when both logmovei and g_bLogging areNow compile is ok but I have problems with building it.
logfunctions.obj : error LNK2001: unresolved external symbol
"struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol
"int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
global in data.h and data.c
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void __cdecl PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Uri
to do is define your two globals in the data.c file as:
FILE *logmovei = (FILE *)NULL;
int g_bLogging = 0;
Of course, the syntax could be slightly different (for one thing since these
are globals they will be zeroed out when the program initializes anyway, but
you get the idea).
And define two extern statements in the data.h file.
extern FILE *logmovei;
extern int g_bLogging;
This should hopefully resolve your linker problems.
regards,
--tom
I even copied what I have in data.h to data.c by copy and paste and deleted the extern to verify that I have no spelling error but the compiler continues to give me the same error.
Uri
Hello Matthias,// printing both to the logfile and to stdout or nul
void PrintLog(FILE *fp, bool bLogging, char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat); vprintf(szFormat, vargs); fflush(stdout);
if (bLogging && fp != (FILE *)NULL) { vfprintf(fp, szFormat, vargs); fflush(fp); }
va_end(vargs);
}
I don't use fastcall, so I don't need __cdecl.
Would fastcall "fasten" my program by 10% or more ?
/Matthias.
It might help a little. I don't know if it will speed the Lion up by 10% but
you never know.
--tom
P.S. Of course, that's all we need is a Lion with sharper claws!!
Sometimes when I get similar errors it's solved by rebuilding the whole program.Here is the function that I have when both logmovei and g_bLogging are global in data.h and data.cNow compile is ok but I have problems with building it.Hey Uri,
Some answers interspersed below.If you are using the "fastcall" linking option under Windows it will causeI copied the function from
http://f11.parsimony.net/forum16635/messages/61760.htm
I tried to compile it with no success.
I get one warning and 4 errors inspite of starting with 2 includes
Here is the code(defs.h and data.h are files that I include in every
file of my program and they include the global varaibles of the program.
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && fpLog != (FILE *)NULL)
{
vfprintf(fpLog, szFormat, vargs);
fflush(fpLog);
}
va_end(vargs);
}
the warning is
warning C4096: '__cdecl' must be used with '...'
The errors are that g_bLogging and fpLog are not defined.
I guess that the error means that I need to have global varaible for
integer and to use logmovei that is defined as external FILE* in data.h
and as FILE* in data.c instead of using fpLog but I first care about the
first warning.
the error you're seeing. Changing the function prototype (and the actual
function) to:
void __cdecl PrintLog(const char *szFormat, ...);
void __cdecl PrintLog(const char *szFormat, ...)
{
etc.
}
should fix things (I should have mentioned this initially). I have this
set up as a define that so that when I compile the program under Linux the
__cdecl is removed by the preprocessor.
As you surmised, you need two global variable to make this work in the
form presented. I think once you get the compiler to recognize the two
globals the remaining errors will likely go away, (if not feel free to
post the *new* errors here
regards,
--tom
logfunctions.obj : error LNK2001: unresolved external symbol "struct _iobuf * logmovei" (?logmovei@@3PAU_iobuf@@A)
logfunctions.obj : error LNK2001: unresolved external symbol "int g_bLogging" (?g_bLogging@@3HA)
Release/main.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
main.exe - 3 error(s), 0 warning(s)
Uri
#include "defs.h"
#include "data.h"
#include "stdarg.h"
//printing both to the logfile and to stdout
void __cdecl PrintLog(const char *szFormat, ...)
{
va_list vargs;
va_start(vargs, szFormat);
vprintf(szFormat, vargs);
fflush(stdout);
if (g_bLogging && logmovei != (FILE *)NULL)
{
vfprintf(logmovei, szFormat, vargs);
fflush(logmovei);
}
va_end(vargs);
}
Uri
I have #include in my data.h that is included in the relevant file so there is no problem.Don't forget to #include stdio.h (with the angle brackets, I suggest to use angle brackets for other compiler supplied .h files, too, instead of the double quotes). stdio.h must be included before "extern FILE * ...".
The __cdecl stuff should not be needed.
Regards,
Dieter
I guess, you really need that #include stdio.h in your data.h, because you probably have some lineI have #include in my data.h that is included in the relevant file so there is no problem.
I did not try to include also stdarg.h in that file.
Every c file of movei includes stdio.h because I start it by
#include "defs.h"
#include "data.h"
I do not know if it is good programming and maybe it is better not to include stdio.h in files that I do not need it.
Return to Archive (Old Parsimony Forum)
Users browsing this forum: No registered users and 31 guests