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

H

Hal Vaughan

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
 
O

owebeeone

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.
 
J

James Kanze

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top