Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » problem with compilation/linking - Duplicate .cpp file in single package
problem with compilation/linking - Duplicate .cpp file in single package [message #11461] |
Fri, 14 September 2007 02:16 |
mr_ped
Messages: 825 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
Hello, I'm trying to use UnitTest++ in my project ( http://unittest-cpp.sourceforge.net/ ) and to create a UPP package from it.
But I have run into the limited UPP builder ...
The source contain two files with the same name:
src/Posix/TimeHelpers.cpp
src/Win32/TimeHelpers.cpp
Only one of them should be used during compile, chosen by the target platform.
There's no problem to add #ifdef PLATFORM_WIN32 into that cpp file, so the cpp will compile without problem.
But during linking the linker gets the same .o twice, thus reporting multiple definitions of some code.
I think the .o file names should reflect that those are two different files, and produce two different .o files (like TimeHelpers.o and TimeHelpers(2).o ?? or srcPosixTimeHelpers.o srcWin32TimeHelpers.o (directory path added as prefix to .o file name? This can still lead to duplicity, if somebody has directory structure .../a/a and .../aa .. so this one will not work, the UPP must cleanly recognize all duplicity and resolve it with generated names which don't conflict ) )
Anyway, IMO another correct solution is to add "exclude from build WHEN" to package settings, so I can exclude the Win32 files on !PLATFORM_WIN32 and exclude the Posix files when on PLATFORM_WIN32.
This still does not solve cpp files with same name in different directories, but it would solve my problem and IMHO it makes sense so You don't need those ugly #ifdef in code, but you can omit whole cpp from building process by flags.
Another problem I run into is that I can't enter "+" into package name when creating new package. I had to edit the dir and .upp files manually on disk to get "UnitTest++" package name.
|
|
|
Goto Forum:
Current Time: Tue May 14 18:31:59 CEST 2024
Total time taken to generate the page: 0.02587 seconds
|