Name the location of include files

The -I preprocessor option allows you to name a directory where the preprocessor searches for and C include files.

This option is valid for both the and the C preprocessors as follows:
  • The preprocessor (esql) processes only include files.

    You specify these include files with the include preprocessor directive $include or EXEC SQL include.

  • The C preprocessor (cc) processes only the C include files.

    You specify these files with the #include preprocessor statement. Because the C preprocessing begins after the compilation is completed, the C include files are processed after the include files.

The preprocessor passes the -I option to the C compiler for processing of C include files (those files that a #include preprocessor statement specifies). The syntax for the -I option is as follows:
esql -Idirectory esqlcprogram.ec

The directory can be on a mounted remote file system if the standard C library functions fopen(), fread(), and fclose() can access them.

The following esql command names the UNIX™ directory /usr/johnd/incls as a directory to search for and C include files within the demo1 program:
esql -I/usr/johnd/incls demo1.ec

Each -I option lists a single directory. To list several directories, you must list multiple -I options on the command line.

To search in both the C:\dorrie\incl and C:\johnd\incls directories in a Windows™ environment, you would need to issue the following command:
esql -IC:dorrie\incl -IC:\johnd\incls demo1.ec
When the preprocessor reaches an include directive, it looks through a search path for the file to include. It searches directories in this sequence:
  1. The current directory
  2. The directories that -I preprocessor options specify (in the order in which you specify them on the command line)
  3. The directory $ONEDB_HOME/incl/esql on a UNIX operating system and the %ONEDB_HOME%\incl\esql in a Windows environment (where $ONEDB_HOME and %ONEDB_HOME% represent the contents of the environment variable of that name)
  4. The directory /usr/include