|
|
In C (and thus C++) when you need a function/class/whatever, you #include
the header file defining it. It's always enough to #include just that one
header file that defines it. You don't have to include any other header
files in order to be able to use the one you want.
If this header file needs other header file (as very often is the case),
it #includes them itself. The problems of repeated definitions (ie. the
same file is #included more than once), which is often illegal (for example,
you can't declare the same class twice) or at least slows parsing, is
avoided with the typical method:
#ifndef _STUFF_H_
#define _STUFF_H_
(some stuff here)
#endif
For some strange reason, which I can't understand, the standard include
files of povray do not do this.
For example, if you #include "textures.inc" you get an error. The reason
is that you didn't #include "colors.inc" before.
That doesn't make sense. If "textures.inc" needs "colors.inc", why doesn't
it #include "colors.inc" by itself?
If I #include "textures.inc" I expect it to work as is.
I have added the #include "colors.inc" at the beginning of "textures.inc",
and no problems, of course. Now I can just #include "textures.inc" and it
works, as it should.
Why the official version is illogical in this way is beyond me.
So this is a request for the next version of povray.
If an include file needs another include file, then add the #include in
the first.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
|
|
In article <37eb3572@news.povray.org>, Nieminen Juha <war### [at] cctutfi> wrote:
> For example, if you #include "textures.inc" you get an error. The reason
>is that you didn't #include "colors.inc" before.
> That doesn't make sense. If "textures.inc" needs "colors.inc", why doesn't
>it #include "colors.inc" by itself?
> If I #include "textures.inc" I expect it to work as is.
This could be accomplished with the existing stuff by declaring a variable in
each file and checking for it... hadn't thought of that before, but I know it
can be a problem... with some of the projects I've done so far I've ran into
this while developing some of the more detailed objects to be included in a
bigger scene. I think what you would check for would be something like:
#ifndef (_Colors_Inc_ID)
#include "colors.inc"
#end
if you need the "colors.inc" file, then have colors.inc declare a variable
itself as:
#declare _Colors_Inc_ID=1;
or something.... maybe a slight revision for 3.5?
PHIL
---------------------------------------------------
Post a reply to this message
|
|