Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » .cpp extension in codegen
Re: .cpp extension in codegen [message #1775103 is a reply to message #1775042] Tue, 24 October 2017 14:56 Go to previous messageGo to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Sorry, there is no way to tell the code generator to use other file extensions at this point. If you'd like that feature, I suggest opening a bug for it.

In the meantime, it's easy enough to do a batch file rename. For example in bash you can do:

for f in *.cc; do mv $f ${f/.cc/.cpp}; done


You would have to rename files in the MakefileTop.mk, CMakeLists.txt (if you use cmake) and replace all the #include statements in the generated code though. You could also automate that in bash, e.g.

sed "s/\.cc/\.cpp/g" MakefileTop.mk > temp.mk; mv temp.mk MakefileTop.mk


But doing that automatically for the #include directives wouldn't work, because it would replace the includes of the runtime library as well, which are fixed with a .hh extension. This would require a more careful script, like this (after the batch renaming above):

for f in *.cpp; do
    sed -i '' -E '/#include "umlrt/!s/#include "([A-Za-z0-9]+)\.hh/#include "\1\.hpp/g' $f
done


If you are not very familiar with sed, this means: for each file f with .cpp extension, edit the file (sed) in-place (-i) without a temporary file ('') using extended regular expressions (-E), considering only the lines where the pattern '#include "umlrt' does *not* occur (!), substituting (s) the pattern '#include "([A-Za-z0-9]+)\.hh' by the pattern '#include \1.hpp' (where \1 is the same as the sequence inside (...) in the first pattern) and do this globally (g), i.e. for every occurrence.

If you are on Windows, you should have Cygwin and you can install sed there. If you are on Linux or macOS you should already have sed built-in.

Out of curiosity, is there any particular reason why you want .cpp/.hpp extensions instead of .cc/.hh?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Registering an UML-RT Package using Extension Points
Next Topic:Eclipse Extension Point
Goto Forum:
  


Current Time: Thu Apr 25 19:38:47 GMT 2024

Powered by FUDForum. Page generated in 0.03337 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top