User forums > Using Code::Blocks

bool in static libs?

<< < (2/3) > >>

Game_Ender:
Well I guess it would be a normal part of windows programming to run you proper through the preprocessor to make sure it doesn't get mangled by windows macros.  That would probably save you all those days.

Rassilon:

--- Quote from: TDragon on March 24, 2006, 09:41:41 pm ---
--- Quote from: Rassilon on March 24, 2006, 09:35:28 pm ---I see that you cannot mix C static libs with c++ ones!

--- End quote ---
Actually, you can. Any decent C++ linker will allow you to interface with C object code, as long as your declarations are marked as C (using the extern "C" construct).

--- End quote ---

I did that actually...I believe I even tried extern on the function....And for some reason CB/link.exe would not see the library until I changed the file ext to cpp...

It could stem from my lack of experience using CB...When I first started I had a hell of a time getting CB to see the linked libraries due to the fact I was combining the Microsoft SDK with the toolkit...Copying all libs and includes over to the toolkit's directories...(Wanted to make my own easy install CD vs the current)...

It might not have been CB but the toolkit link.exe...I found it rather strange but atleast I got things working...

TDragon:
It's not Code::Blocks' fault, nor the toolkit's fault, just your own inexperience in doing things like this. Basically, if you want to use external (i.e. library) C functions and variables in your C++ code, you must (as with any library) declare the functions and variables for the C++ code, and you must surround the declarations with extern "C" { ... }. Since the majority of C libraries have a header that you include to use the library, it's simplest to simply surround the #include directive with the extern "C" { } construct.

thomas:

--- Quote from: TDragon on March 24, 2006, 10:56:23 pm ---It's not Code::Blocks' fault, nor the toolkit's fault, just your own inexperience in doing things like this. Basically, if you want to use external (i.e. library) C functions and variables in your C++ code, you must (as with any library) declare the functions and variables for the C++ code, and you must surround the declarations with extern "C" { ... }.
--- End quote ---
The problem had nothing to do with extern "C", though. ;)

TDragon:
No, but my answer to the statement that C libraries couldn't be used with C++ ones did. True, the question of whether they can or not has no bearing on the solution to Rassilon's problem...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version