open-dis / open-dis-cpp

C++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
BSD 2-Clause "Simplified" License
90 stars 65 forks source link

Use "" for local includes #52

Open phoppermann opened 3 years ago

phoppermann commented 3 years ago

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"

leif81 commented 3 years ago

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

rodneyp290 commented 3 years ago

#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>)

phoppermann commented 3 years ago

@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?

leif81 commented 3 years ago

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 commented 3 years ago

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.

phoppermann commented 3 years ago

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.