Page 1 of 1

System Files Bug

Posted: Tue Aug 19, 2008 6:14 am
by talexander
I ran into an issue when referring to ucosmcfc.h, getting C++ linkage errors when referring to it from C files. ucosmcfc.c is used by both C and C++ files and the variable critical_count is defined as an extern, without any previous extern "C" definition. The system files build ok, but referring to ucosmcfc from any new C file in the project will fail.

I suggest changing ucosmcfc.h in future releases so that

#ifdef __cplusplus
extern "C"
{
#endif

is placed at the begining of the file.

Re: System Files Bug

Posted: Wed Aug 20, 2008 12:57 pm
by lgitlitz
There is already an extern "c" in this header but for some reason this variable was not in the scope. I fixed this for the release, thanks for pointing it out.

-Larry

Re: System Files Bug

Posted: Wed Aug 20, 2008 10:20 pm
by rnixon
Just out of curiosity, why not name all the files you create as .cpp instead of .c? That way you can always use any C++ calls without problems. If you don't want to use C++, just code in straight C, but still name the file .cpp to take advantage of additional type checking.

Re: System Files Bug

Posted: Thu Aug 21, 2008 1:42 pm
by talexander
I'm doing a lot of work with a pre-existing codebase that is also used for non-netburner systems. So, I do use cpp extensions where I can with new files, but it's not always possible.