Archived
This forum has been archived. Please start a new discussion on GitHub.
Include syntax of generated files.
in Help Center
I am using #include "..." syntax in an ice input file and the generated code is changing it to #include <...>. This makes it hard to create -I paths to access the files. There is a subtle difference between the following:
#include <xyz.h>
#include "xyz.h"
and this difference is sometimes important. In my case I'm moving generated header files to a public include dir. Putting -I. on the include path will not work because -I. means the current directory of compilation process whereas "xyz.h" means current dir of the file in which the #include "xyz.h" is located. Note that '-I.' is not always even the current dir of the .cpp file being compiled.
Can the generated code preserve the quotes or angle brackets as they are in the input file? I suppose it may be hard to do because the preprocessor has already removed this information. Just thougt I'd ask before I make a workaround.
#include <xyz.h>
#include "xyz.h"
and this difference is sometimes important. In my case I'm moving generated header files to a public include dir. Putting -I. on the include path will not work because -I. means the current directory of compilation process whereas "xyz.h" means current dir of the file in which the #include "xyz.h" is located. Note that '-I.' is not always even the current dir of the .cpp file being compiled.
Can the generated code preserve the quotes or angle brackets as they are in the input file? I suppose it may be hard to do because the preprocessor has already removed this information. Just thougt I'd ask before I make a workaround.
0
Comments
-
Hi John,
Section 4.4.3 of the Ice manual states the following:#include directives can appear only at the beginning of a Slice source file, that is, they must precede all other Slice definitions. In addition, only #include directives using the <>-syntax to specify a file name are permitted; use of the ""-syntax is not supported.
The Ice source code also moves generated header files. With careful use of the -I and --include-dir options, it should be possible to achieve the desired result. Let us know if you're still having trouble.
Take care,
- Mark0 -
Can the <> include path information?
// -*- mode: idl -*-
#ifndef NavUpdate_ice
#define NavUpdate_ice
#ifndef NavData_ice
# include <cnav/NavData.ice> // << See here
#endif
module cnav
{
interface NavUpdate
{
nonmutating void update(NavData data);
};
};
#endif /* NavUpdate_ice */
The manual is ambiguous:
• #include directives can appear only at the beginning of a Slice source file, that is, they must precede all other Slice definitions. In addition, only
#include directives using the <>-syntax to specify a file name are permitted; use of the ""-syntax is not supported. For example:
#include <File1.ice> // OK
#include "File2.ice" // Not supported!
Doesn't say no '/'. I tried it and it doesn't work.0 -
Can the <> include path information?
- Mark0 -
mes wrote:...using the -I and --include-dir options.
Ok now it works. Looks like the --include-dir puts its argument string into generated file between the <> before the file name. <arg/file.h>
Eample: $ slice2cpp --include-dir CNAV ...
Produces: include <CNAV/NavData.h>
That works for me.
The documenation (both --help and pdf manual) doesn't quite make this clear. Here's what command line help says.
--include-dir DIR Use DIR as the header include directory in source files.0