POV-Ray : Newsgroups : povray.general : #include vs #require Server Time
5 Aug 2024 06:12:52 EDT (-0400)
  #include vs #require (Message 1 to 4 of 4)  
From: sharl
Subject: #include vs #require
Date: 25 Oct 2002 20:20:05
Message: <web.3db9de67c659261a49b801190@news.povray.org>
Would it be possible to add a #require command, as in php.
This would add the file only *once* for each scene, no matter
how often the #require"this_file" is found.

Or is there already a good way to avoid multiple including of a file ?
Thanks.
--
sharl.


Post a reply to this message

From: Timothy R  Cook
Subject: Re: #include vs #require
Date: 25 Oct 2002 20:21:01
Message: <3db9dfed$1@news.povray.org>
sharl wrote:
> Or is there already a good way to avoid multiple including of a file ?
> Thanks.

Planning ahead?

-- 
Tim Cook
http://empyrean.scifi-fantasy.com
mirror: http://personal.lig.bellsouth.net/lig/z/9/z993126

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Tim Nikias
Subject: Re: #include vs #require
Date: 25 Oct 2002 20:39:50
Message: <3db9e456@news.povray.org>
In every of my include files, I have a parameter named
_tnw_includefile_ending_

So for my io_macs.inc this would be
_tnw_io_macs_inc_

And its just declared as 1 (similiar to true).

When a different file is based on such an include
file, it checks if that parameter is already declared,
and only includes if its not (using #ifndef).

This doesn't hinder the user from including it once
again AFTER some other include has included it,
but it takes care that all required files will be loaded
at least once, and won't issue warnings.

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde

> Would it be possible to add a #require command, as in php.
> This would add the file only *once* for each scene, no matter
> how often the #require"this_file" is found.
>
> Or is there already a good way to avoid multiple including of a file ?
> Thanks.
> --
> sharl.
>
>
>


Post a reply to this message

From: Christopher James Huff
Subject: Re: #include vs #require
Date: 25 Oct 2002 21:02:29
Message: <chrishuff-5B0C8F.20553425102002@netplex.aussie.org>
In article <web.3db9de67c659261a49b801190@news.povray.org>,
 "sharl" <le.### [at] freefr> wrote:

> Would it be possible to add a #require command, as in php.
> This would add the file only *once* for each scene, no matter
> how often the #require"this_file" is found.
> 
> Or is there already a good way to avoid multiple including of a file ?

The usual way is to use an "inclusion guard", something like this:

#ifndef MYFILE_INC
#declare MYFILE_INC = true;

...file contents...

#end

The official include files combine this with a way of saving the version 
and restoring it at the end of the file.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.