Proto-Functions: Declaring in one file, using in another?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hal Vaughan

    Proto-Functions: Declaring in one file, using in another?

    I have a file where I'm putting a lot of variable definitions. Some of them
    will be maps that include references to functions. This file will be
    processed (by include) before other files are processed.

    If I put protofunction definitions in this definition file and the actual
    functions in another file, are there any non-obvious consequences to this?

    Thanks!

    Hal
  • owebeeone@gmail.com

    #2
    Re: Proto-Functions: Declaring in one file, using in another?

    On Mar 14, 2:49 pm, Hal Vaughan <h...@halblog.c omwrote:
    I have a file where I'm putting a lot of variable definitions.  Some of them
    will be maps that include references to functions.  This file will be
    processed (by include) before other files are processed.
    >
    If I put protofunction definitions in this definition file and the actual
    functions in another file, are there any non-obvious consequences to this?
    There are some significant consequences, some that you may or may not
    care about.

    The FAQ has alot on include files. If it does not satsify your
    questions, please post a more specific question.

    Comment

    • James Kanze

      #3
      Re: Proto-Functions: Declaring in one file, using in another?

      On Mar 14, 4:49 am, Hal Vaughan <h...@halblog.c omwrote:
      I have a file where I'm putting a lot of variable definitions.
      Some of them will be maps that include references to
      functions. This file will be processed (by include) before
      other files are processed.
      If I put protofunction definitions in this definition file and
      the actual functions in another file, are there any
      non-obvious consequences to this?
      It depends on what you mean by "non-obvious". In general, any
      time you expect to use the name of a function in a source file
      other than where it is defined, you should put its declaration
      in a separate header file, to be included both in the source
      file where you define the function, and in all other source
      files which use it. And make sure that all of the objects whose
      source file includes that header (directly or indirectly) are
      declared as depending on it in the make file---most versions of
      make have different astuces to help automate this. (And any
      time you don't expect to use the name of a function in another
      source file, of course, you should put the function in an
      anonymous namespace.)

      --
      James Kanze (GABI Software) email:james.kan ze@gmail.com
      Conseils en informatique orientée objet/
      Beratung in objektorientier ter Datenverarbeitu ng
      9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

      Comment

      Working...