By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Mar 14 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mar 14, 2:49*pm, Hal Vaughan <h...@halblog.comwrote:
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.
Mar 14 '08 #2

P: n/a
On Mar 14, 4:49 am, Hal Vaughan <h...@halblog.comwrote:
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:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Mar 14 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.