open-dis-cpp icon indicating copy to clipboard operation
open-dis-cpp copied to clipboard

Use "" for local includes

Open phoppermann opened this issue 4 years ago • 6 comments

e.g. in https://github.com/open-dis/open-dis-cpp/blob/a9f9f26cb5eff47235559135f39c47ac57a82add/src/dis6/AcknowledgePdu.cpp#L1

#include <dis6/AcknowledgePdu.h> to #include "AcknowledgePdu.h"

phoppermann avatar Mar 16 '21 08:03 phoppermann

Thanks @phoppermann , would you like to submit a small pull request for this?

leif81 avatar Mar 31 '21 12:03 leif81

#include <dis6/AcknowledgePdu.h> seems to be the convention in all the dis6 & dis7 cpp files at the moment. I'm assuming convention is actually from the initial XML generated cpp as that's the style used in the initial check in https://github.com/open-dis/open-dis-cpp/blob/a2525d676fac6de4f6d94a003e23fbdfca06b6f3/cpp/DIS/AcknowledgePdu.cpp#L1

Is there any particular reasoning for/against changing it?

I believe the current method, does require you to explicitly add ./src as a include directory (e.g. adding -I./src to the g++ command), although that is also required for the any Util includes (e.g. #include <utils/DataStream.h>)

rodneyp290 avatar Apr 01 '21 00:04 rodneyp290

@rodneyp290 yes, it works normally. However, the include syntax with <> suggests that it's a system include (which is not the case here). See also https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html. Apart from theoretical considerations, this can also have practical consequences e.g. in the following case: If you have installed OpenDis on your system and build it, the compiler might use the installed header instead of your own one.

@leif81 are the files generated by xmlpg or was xmlpg only used for the initial version?

phoppermann avatar Apr 15 '21 07:04 phoppermann

I think the use of <> is the right one. Open DIS is a library that will get installed on the system e.g. /usr/local/include/dis6/Acknowledge.h. Then in your app you would do #include <dis6/Acknowledge.h> and it just works because that's a standard system search path no?

leif81 avatar Apr 15 '21 11:04 leif81

In the early days the source files here were repeatedly generated by xmlpg and blindly overwritten everything here, but that no longer is the case. Corrections and improvements are being made directly to the source here now.

leif81 avatar Apr 15 '21 11:04 leif81

I think the use of <> is the right one. Open DIS is a library that will get installed on the system e.g. /usr/local/include/dis6/Acknowledge.h. Then in your app you would do #include <dis6/Acknowledge.h> and it just works because that's a standard system search path no?

Yes. However, that's not the point of the discussion. It's about the includes inside Open DIS.

phoppermann avatar Apr 19 '21 11:04 phoppermann