Namespaces |
Top Previous Next |
What is translated > File layout > Namespaces
There is an option, to create a namespace for each unit. In C++ header files the scope expressions are put in front of types and constants from other units and in the C++ implementation files according uses clauses are inserted.
Example:
unit Namespace1; interface type
PInteger = ^integer; ...
unit Namespace2; interface uses Namespace1; type
PInt = PInteger;
implementation const
_pint1 : PInteger = Nil; _pint2 : PInt = Nil;
end.
Namespace2 is translated to the header:
#ifndef Namespace2H #define Namespace2H
#include "Namespace1.h"
namespace Namespace2 {
typedef Namespace1::PInteger PInt;
} // namespace Namespace2
#endif // Namespace2H
and the implementation:
#include <vcl.h> #pragma hdrstop
#include "Namespace2.h"
using namespace Namespace1;
namespace Namespace2 {
PInteger _pint1 = NULL; PInt _pint2 = NULL;
} // namespace Namespace2
Remarks:
The hpp-headers from C++Builder have a using clause at their end. That's why Delphi2Cpp doesn't insert namespace qualifiers and using clauses for that files. The other way round: If a file has the name of a VCL unit, an according uses clause is inserted.
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |