Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Mikko Newsgroups: comp.lang.c Subject: Re: Writing own source disk Date: Wed, 5 Jun 2024 11:19:36 +0300 Organization: - Lines: 30 Message-ID: References: <87sexvm1lr.fsf@bsb.me.uk> <87mso2mky5.fsf@bsb.me.uk> <87h6e91r91.fsf@nosuchdomain.example.com> <87cyox1r5e.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 05 Jun 2024 10:19:37 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f59ac17d296a13bc5d3841a994cc1bf4"; logging-data="951511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GO26H7ESoO/GwaQBKUj6L" User-Agent: Unison/2.2 Cancel-Lock: sha1:rpGlKGrYBbPdw6if45X6sVg6rSA= Bytes: 2216 On 2024-06-04 00:35:25 +0000, Keith Thompson said: > Keith Thompson writes: >> bart 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. An operating system might refuse to open an already opened file. There is no good reason to refuse when all accesses are for read-only but a supid operating system might think otherwise. -- Mikko