diff options
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 25 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 5 |
2 files changed, 25 insertions, 5 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 8227dc8f445..b0c4f5666db 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -214,12 +214,12 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& Slice::Gen::~Gen() { - H << '\n'; + H << "\n\n#endif\n"; C << '\n'; if(_impl) { - implH << '\n'; + implH << "\n\n#endif\n"; implC << '\n'; } } @@ -280,7 +280,15 @@ Slice::Gen::generate(const UnitPtr& p) } FileTracker::instance()->addFile(fileImplC); - implH << "#pragma once\n"; + string s = fileImplH; + if(_include.size()) + { + s = _include + '/' + s; + } + transform(s.begin(), s.end(), s.begin(), ToIfdef()); + implH << "#ifndef __" << s << "__"; + implH << "\n#define __" << s << "__"; + implH << '\n'; } string fileH = _base + "." + _headerExtension; @@ -314,7 +322,16 @@ Slice::Gen::generate(const UnitPtr& p) printHeader(C); printGeneratedHeader(C, _base + ".ice"); - H << "#pragma once\n"; + + string s = fileH; + if(_include.size()) + { + s = _include + '/' + s; + } + transform(s.begin(), s.end(), s.begin(), ToIfdef()); + H << "\n#ifndef __" << s << "__"; + H << "\n#define __" << s << "__"; + H << '\n'; validateMetaData(p); diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 941b2a90e12..9d05ca2a8b5 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -7,7 +7,8 @@ // // ********************************************************************** -#pragma once +#ifndef GEN_H +#define GEN_H #include <Slice/Parser.h> #include <IceUtil/OutputUtil.h> @@ -450,3 +451,5 @@ private: }; } + +#endif |