User forums > Using Code::Blocks
bool in static libs?
rassilon:
Am I supposed to get a compile error:
missing ')' before identifier
when using a bool in a function:
void testSpot(bool t);
compiling with visual toolkit 2003 and SDK 2003?
I know that when I compile a console app etc I dont get these issues...Also if I change to int it passes...
I guess Im missing a header but for the life of me I cannot remember what header contains bool...
Thanks in advance...
thomas:
bool is a C++ keyword, so you don't need any headers for it.
However, Microsoft is notorious about using CUMs (Completely Useless Macro(TM)) everywhere, and it is entirely possible that bool is redefined as something else...
EDIT: Of course it is also possible that the error is in the last line before the one you pasted. Maybe you forgot the closing parenthese in the line before, then the error would show in that place, too.
thomas:
Here is a good example of what can happen to you due to CUMs:
--- Code: ---// this would typically be in another compilation unit
// and the header be included in the main program
class TextEditor
{
//...
public:
//...
void LoadFile(const char* name)
{
//...
};
char * FindText(const char* search)
{
return (char*) 0; // ok, there are better search algorithms ;-)
};
};
// the main program goes here...
#include <windows.h>
int main()
{
TextEditor t;
t.LoadFile("foo.txt");
char *c = t.FindText("some text"); // oh surprise... a missing symbol
return 0;
}
--- End code ---
You will not be able to build this because your class has an unresolved symbol. Why is there an unresolved symbol, you wonder. Everything is correct, isn't it?
Yes, except that some freaking moron at Microsoft deemed it a good idea to implement Unicode support by defining a macro for each and every Win32 API function name (such as for example FindText).
Thus, if you include "windows.h" after including your own header, your member function is renamed to FindTextA or FindTextU, depending on whether you compile with Unicode support or without!
You can spend weeks searching for errors in your code where there are none, and you will never find out why it does not work. Aren't macros just great?
Rassilon:
--- Quote from: thomas on March 23, 2006, 06:22:11 pm ---
You will not be able to build this because your class has an unresolved symbol. Why is there an unresolved symbol, you wonder. Everything is correct, isn't it?
Yes, except that some freaking moron at Microsoft deemed it a good idea to implement Unicode support by defining a macro for each and every Win32 API function name (such as for example FindText).
Thus, if you include "windows.h" after including your own header, your member function is renamed to FindTextA or FindTextU, depending on whether you compile with Unicode support or without!
You can spend weeks searching for errors in your code where there are none, and you will never find out why it does not work. Aren't macros just great?
--- End quote ---
lol you sound like me when I rattle on microshaft...
I tend to try to stay away from mixing code like that anyways but I fully know what you mean...
The problem I had above I failed to name my file with the cpp extension...After doing so not only did bool become defined but I also was able to link my library successfully in the main project...
I see that you cannot mix C static libs with c++ ones!
Thanks!
TDragon:
--- 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).
Navigation
[0] Message Index
[#] Next page
Go to full version