User forums > Using Code::Blocks
C naming convention and underscores
ikolev:
Hi guys,
For a first post, let me say first that I'm really impressed by Code::Blocks. It's simply inspiring... a powerful open-source IDE for C++ (and properly conceived and designed, which makes it stand out from the similar projects) - sounds like a dream coming true. I really feel strong urge to help with the development. I hope I'll find the time one day. For now, I'm happy that I compiled successfully the SVN head, so there's a warm sense of confidence that if I'm really bugged by some bug or glitch (like the missing support for last tab switching on Ctrl-Tab, which IIRC is a Scintilla shortcoming), I could try to fix it myself. That's a feeling you don't get with commercial software. Of course, there are still small glitches and weaknesses compared to the well-known giant of C++ IDE's, but I'm sure these will be worked out in time. BTW, I think it would be a good idea to put download links to a much more recent build - the progress since October's RC2 is enormous.
Now to the first problem I couldn't quickly solve myself. I tried to build one of my libraries ( http://www.ikolev.com/DebugTools/ ) with GNU C++, and I got a link time error " undefined reference to `timeGetTime@0' ". The library uses timeGetTime() from libwinmm.a, which as I can see in the binary of the library is named _timeGetTime@0. However, GNU C++ obviously doesn't put a leading underscore when compiling my source code. Question is why? I'm quite new to GNU C++ so maybe I miss something about its options. I have distant memories from more than 10 years ago when I used Watcom C and had similar naming problems (which I had learned how to solve then, but can't remember now - it was somehow related to the calling convention - cdecl, fastcall, etc.). It's strange that this problem doesn't appear when compiling with Dev-Cpp 4.9.9.2. I hope someone has a quick answer to this...
Thanks,
Ivan
killerbot:
--- Quote ---BTW, I think it would be a good idea to put download links to a much more recent build - the progress since October's RC2 is enormous.
--- End quote ---
Follow the nightlies link on the codeblocks.org, or in here in the forum go to the nightlies section.
Game_Ender:
--- Quote from: killerbot on March 03, 2006, 12:14:46 am ---Follow the nightlies link on the codeblocks.org, or in here in the forum go to the nightlies section.
--- End quote ---
I think he wants those to be displayed more prominently. I think there should be a notice right below the RC2 message on the front page that user should try the nightly builds if they have problems.
About the library. Both C and C++ compilers do name mangling, although the C method is standard, the compiler just puts a "_" in front of the name which is why you set "_timeGetTime()" in the binary. Can you set the compiler to show the full command line and then post the results.
Ceniza:
Be sure to have something like this when you compile with C++ trying to access things compiled with C:
--- Code: (cpp) ---#ifdef __cplusplus
extern "C" {
#endif
int timeGetTime(); // it's just a guess it returns int, just be sure to write it correctly here
// anything other declarations go here
#ifdef __cplusplus
}
#endif
--- End code ---
That should do.
It's because of differences in name mangling, just like Game_Ender said.
Game_Ender:
The reason you can just include the std C headers and not have to worry about this is because they already have all the proper defines setup to include the "extern C" if you are using a C++ compiler.
Navigation
[0] Message Index
[#] Next page
Go to full version