Deutsch   English   Français   Italiano  
<v3mfrd$an45$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Writing own source disk
Date: Tue, 4 Jun 2024 09:30:53 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <v3mfrd$an45$2@dont-email.me>
References: <v3hmha$3banl$1@dont-email.me> <87sexvm1lr.fsf@bsb.me.uk>
 <v3iu4n$3i607$1@dont-email.me> <87mso2mky5.fsf@bsb.me.uk>
 <v3k49t$3rdhi$1@dont-email.me> <87h6e91r91.fsf@nosuchdomain.example.com>
 <87cyox1r5e.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 04 Jun 2024 09:30:54 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7740955b17fd8df0cccaba227b9e3b39";
	logging-data="351365"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+FOLR7D/mzHNhlhrSkrskYio+f35oTmCo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:LPrI+cvbuZBOW4URDh2xQ7vrfTo=
In-Reply-To: <87cyox1r5e.fsf@nosuchdomain.example.com>
Content-Language: en-GB
Bytes: 2847

On 04/06/2024 02:35, Keith Thompson wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> I assume you can use __FILE__ with #embed? (I can do that with my
>>> version of it).
>>
>> Yes, but not reliably.
>>
>> __FILE__ expands to "The presumed name of the current source file (a
>> character string literal)".  That's rather vague.
>>
>> With gcc and clang, it expands to the file name argument given to the
>> compiler, or to the argument of the #include directive.  The running
>> program may or may not be able to access the source file using that
>> name.  The source file might not even exist when the program runs.
> 
> I was thinking of using __FILE__ to access the source file at run time.
> #embed is of course handled at compile time.  It's very likely, but
> still not quite guaranteed, that `#embed __FILE__` will be able to
> access the source file.
> 

The key question for that will be directory handling.  If everything is 
being done within the same directory, than I'd expect "#embed __FILE__" 
to work fine.  But if you are calling the compiler from a different 
directory, specifying a path for the source file, that might not be 
reflected in __FILE__.  The result could vary between compilers.

There is also the possibility that the search path for #embed might 
result in finding a different file with the same name.  But I think that 
would probably need specific command-line switches to specify the #embed 
search path (again, this will be compiler-specific).