Fun with include files.


R. Clayton (rclayton@monmouth.edu)
Fri, 16 Jun 2000 13:29:21 -0400 (EDT)


I wanted to make sure my program compiles in your environment.

    $ ls
    HeaderField.h Mailbox.h Parser.h global_defs.h
    MailTool.h Message.h compile-files main.cpp

    $ cxx -c main.cpp
    cxx: Error: MailTool.h, line 21: could not open source file "Message.h"
    #include <Message.h>
    --------------------^
    cxx: Error: MailTool.h, line 22: could not open source file "Mailbox.h"
    #include <Mailbox.h>
    --------------------^
    cxx: Info: 2 errors detected in the compilation of "main.cpp".

    $

  The interpretation of <> includes and "" includes is tricky and variable, but
  a compiler (actually, the pre-processor) usually searches only the official
  system directories for <> included files, while the compiler searches the
  current working directory as well as the official system directories for ""
  included files. Of course, then you have to factor in compiler behavior when
  the command line contains the -Idir option.

  Changing

    #include <Message.h>
    #include <Mailbox.h>

  to

    #include "Message.h"
    #include "Mailbox.h"

  in MailTool.h fixes things:

    $ ls
    HeaderField.h Mailbox.h Parser.h global_defs.h
    MailTool.h Message.h compile-files main.cpp

    $ cxx -c main.cpp

    $ cxx -o readmbox main.o

    $



This archive was generated by hypermail 2.0b3 on Fri Aug 11 2000 - 15:25:05 EDT