envire / envire-envire_core

Core part for the Environment Representation library
BSD 2-Clause "Simplified" License
7 stars 13 forks source link

#pragma once not working in msys2/autoproj #18

Closed mmaurus closed 5 years ago

mmaurus commented 8 years ago

pragma once is not working properly for all build systems due to its implementation.

Looks like it is only preventing reloading of the same file (same filepath). If the build system is copying the headers to the build folder, then there will be a multiple loading of the header files which result in redeclaration compile errors! http://stackoverflow.com/questions/787533/is-pragma-once-a-safe-include-guard, second reply

arneboe commented 8 years ago

If the build system copies files to the build folder, the source folder should not be on the include path. Can you elaborate on how your build system is set up? Are you using the provided CMake files or something else?

I would like to avoid using ifdef guards if at all possible because they are a pain-in-the-ass to maintain. E.g. if file names change the guards do not change automatically. If two files in different folders have the same name, they will most likely have the same include-guard etc.

planthaber commented 8 years ago

The build system is autoproj, but msys2 does not support symbolic links on windows OS, ln -s is mapped to a copy instead of linking:

https://sourceforge.net/p/msys2/wiki/How%20does%20MSYS2%20differ%20from%20Cygwin/ Point 4. in Section "Runtime"

But I can imagine this error could come from mixing local and path includes in the tests ( "" vs. <>), at least path includes should result in using the same file.

arneboe commented 8 years ago

But I can imagine this error could come from mixing local and path includes in the tests ( "" vs. <>), at least path includes should result in using the same file.

Nope, the tests do not contain local includes.

Mixing local and path includes shouldn't be a problem, either. If everything is copied to the build folder, local and path includes should result in the same file being included. My guess is that somehow the src folder is part of the include-path.

Is there a way that I can get access to a windows machine an test it somehow?

arneboe commented 8 years ago

Any updates on this? Otherwise I will close it as invalid

mmaurus commented 8 years ago

Well my solution was using include guards! And there are mixed local and path includes in envire_core/src/graph

arneboe commented 8 years ago

I removed all replaced all relative includes with path includes. Can you test if it works?

chhtz commented 8 years ago

Path includes are actually a bit annoying if you are editing these files. In that case the old file is still included until the build is finished and installed -- and usually the build will fail, until the new header is included ...

arneboe commented 8 years ago

@chhtz If the build system is setup correctly it should prepend the local build root to the include PATH. I.e. path includes while building will use the correct header. But I am not sure if that really works :-)

arneboe commented 5 years ago

closing as no longer relevant?