-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include guards should contain namespace #51
Comments
I wrote this script which seems to make the right changes, but thought it might be best to wait for the current PRs to be resolved first, committing and making a PR. Putting here for safe keeping, and further discussion. Although maybe the (script to be run in root of repo) pushd src/dis6/
for hf in *.h; do
sed -Ei 's/^(#(ifndef|define|endif\s+\/\/)\s+)([A-Z_]+_(H|h))/\1OPENDIS6_\3/' $hf;
done
popd
pushd src/dis7/
for hf in *.h; do
sed -Ei 's/^(#(ifndef|define|endif\s+\/\/)\s+)([A-Z_]+_(H|h))/\1OPENDIS7_\3/' $hf;
done
popd
pushd src/utils/
for hf in *.h; do
sed -Ei 's/^(#(ifndef|define|endif\s+\/\/)\s+)([A-Z_]+_(H|h))/\1OPENDIS_UTILS_\3/' $hf;
done
popd |
This should be implemented in xmlpg as well. |
#pragma once looks like it has very good compiler support now so that seems like a good option to me too. Feel free to submit PR for that. |
@rodneyp290 could you change your script to use |
Took a little bit of fiddling to get it right, but I think this replaces and delete all the necessary lines. pushd src/dis6/
for hf in *.h; do
sed -Ei 's/^#ifndef\s+[A-Z0-9_]+_(H|h)/#pragma once/' $hf;
sed -Ei '/^#define\s+(\/\/\s+|)[A-Z_]+_(H|h)/d' $hf;
sed -Ei '/^#endif/d' $hf;
done
popd
pushd src/dis7/
for hf in *.h; do
sed -Ei 's/^#ifndef\s+[A-Z0-9_]+_(H|h)/#pragma once/' $hf;
sed -Ei '/^#define\s+(\/\/\s+|)[A-Z_]+_(H|h)/d' $hf;
sed -Ei '/^#endif/d' $hf;
done
popd
pushd src/utils/
for hf in *.h; do
sed -Ei 's/^#ifndef\s+[A-Z0-9_]+_(H|h)/#pragma once/' $hf;
sed -Ei '/^#(define|endif)\s+(\/\/\s+|)[A-Z_]+_(H|h|)/d' $hf;
done
popd This doesn't include |
I'm on "vacation" this week away from my PC. Can you run the script and submit the change as a PR? I'm available to click merge. |
Turns out I had @kurtsansom's #44 PR checked out when writing the script, so I'd prefer to wait until that is completed, and then merged. |
Turns out I underestimated git merge, as it merged almost flawlessly. So I deciding to leave that file with include guards, so that when #44 merges with the click of a button. PR incoming |
Replace Include Guards with #pragma once (Issue #51)
to avoid potential name clashes
e.g. in
open-dis-cpp/src/dis6/AcknowledgePdu.h
Line 2 in a9f9f26
ACKNOWLEDGEPDU_H
toDIS_ACKNOWLEDGEPDU_H
alternatively: use
#pragma once
The text was updated successfully, but these errors were encountered: