Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Logic doesn't apply to the real world. -- Marvin Minsky


devel / comp.lang.c / Re: Implicit String-Literal Concatenation

SubjectAuthor
* Implicit String-Literal ConcatenationLawrence D'Oliveiro
+* Re: Implicit String-Literal ConcatenationJanis Papanagnou
|`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
| `- Re: Implicit String-Literal Concatenationbart
+- Re: Implicit String-Literal ConcatenationBlue-Maned_Hawk
+- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
+* Re: Implicit String-Literal ConcatenationƁukasz 'Maly' Ostrowski
|`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
| `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
|  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
|   `- Re: Implicit String-Literal ConcatenationJanis Papanagnou
+- Re: Implicit String-Literal ConcatenationKaz Kylheku
`* Re: Implicit String-Literal ConcatenationMike Sanders
 +* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
 |`- Re: Implicit String-Literal ConcatenationMike Sanders
 `* Re: Implicit String-Literal ConcatenationDavid Brown
  +- Re: Implicit String-Literal ConcatenationMike Sanders
  +* Re: Implicit String-Literal Concatenationbart
  |`* Re: Implicit String-Literal ConcatenationDavid Brown
  | `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |  `* Re: Implicit String-Literal ConcatenationKaz Kylheku
  |   `* Re: Implicit String-Literal ConcatenationDavid Brown
  |    `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     +* Re: Implicit String-Literal Concatenationbart
  |     |`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     | `* Re: Implicit String-Literal Concatenationbart
  |     |  +* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |     |  |`- Re: Implicit String-Literal Concatenationbart
  |     |  `* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |   `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |    `* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |     +* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     |`* Re: Implicit String-Literal ConcatenationScott Lurndal
  |     |     | `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |  `* Re: Implicit String-Literal Concatenationbart
  |     |     |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |    `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     |     `* Re: Implicit String-Literal ConcatenationKeith Thompson
  |     |     |      `- Re: Implicit String-Literal ConcatenationJanis Papanagnou
  |     |     `- Re: Implicit String-Literal ConcatenationKeith Thompson
  |     `* Re: Implicit String-Literal ConcatenationDavid Brown
  |      `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
  |       `* Re: Implicit String-Literal ConcatenationDavid Brown
  |        `* Re: Implicit String-Literal ConcatenationKaz Kylheku
  |         `- Re: Implicit String-Literal ConcatenationDavid Brown
  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
   +* Re: Implicit String-Literal ConcatenationKeith Thompson
   |`- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
   `* Re: Implicit String-Literal Concatenationbart
    `* Re: Implicit String-Literal ConcatenationDavid Brown
     +* Re: Implicit String-Literal Concatenationbart
     |+- Re: Implicit String-Literal ConcatenationDavid Brown
     |+* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||+* Re: Implicit String-Literal ConcatenationMalcolm McLean
     |||+* Re: Implicit String-Literal ConcatenationDavid Brown
     ||||`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     |||| +- Re: Implicit String-Literal ConcatenationKeith Thompson
     |||| `* Re: Implicit String-Literal ConcatenationRichard Harnden
     ||||  `- Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     |||`- Re: Implicit String-Literal ConcatenationKeith Thompson
     ||`* Re: Implicit String-Literal Concatenationbart
     || +* Re: Implicit String-Literal ConcatenationRichard Harnden
     || |`* Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || | `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |  `* Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |    +- Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |    `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     || |     `* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |      `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
     || |       +* Re: Implicit String-Literal ConcatenationKaz Kylheku
     || |       |`* Re: Implicit String-Literal ConcatenationKeith Thompson
     || |       | +* Re: Implicit String-Literal ConcatenationKaz Kylheku
     || |       | |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     || |       | +- Re: Implicit String-Literal ConcatenationChris M. Thomasson
     || |       | `- Re: Implicit String-Literal ConcatenationRichard Harnden
     || |       `- Re: Implicit String-Literal ConcatenationKeith Thompson
     || +* Re: Implicit String-Literal ConcatenationDavid Brown
     || |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     || `* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||  `* Re: Implicit String-Literal ConcatenationJanis Papanagnou
     ||   `* Re: Implicit String-Literal ConcatenationKeith Thompson
     ||    `* Re: Implicit String-Literal ConcatenationKaz Kylheku
     ||     `- Re: Implicit String-Literal ConcatenationJames Kuyper
     |`- Re: Implicit String-Literal ConcatenationKeith Thompson
     `* Re: Implicit String-Literal ConcatenationKeith Thompson
      +* Re: Implicit String-Literal Concatenationbart
      |`* Re: Implicit String-Literal ConcatenationKeith Thompson
      | `* Re: Implicit String-Literal Concatenationbart
      |  +- Re: Implicit String-Literal ConcatenationKeith Thompson
      |  +* Re: Implicit String-Literal ConcatenationtTh
      |  |`- Re: Implicit String-Literal ConcatenationScott Lurndal
      |  `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |   `* Re: Implicit String-Literal ConcatenationKeith Thompson
      |    `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |     `* Re: Implicit String-Literal ConcatenationDavid Brown
      |      `* Re: Implicit String-Literal ConcatenationScott Lurndal
      |       +* Re: Implicit String-Literal ConcatenationScott Lurndal
      |       |`* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
      |       | `* Re: Implicit String-Literal Concatenationbart
      |       |  `* Re: Implicit String-Literal ConcatenationLawrence D'Oliveiro
      |       `- Re: Implicit String-Literal ConcatenationDavid Brown
      `* Re: Implicit String-Literal ConcatenationDavid Brown

Pages:12345
Re: Implicit String-Literal Concatenation

<urq7tu$m1jm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33928&group=comp.lang.c#33928

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 16:30:05 +0100
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <urq7tu$m1jm$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me> <87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Feb 2024 15:30:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f99e7338f93fdbe8ddcb741f55a4912";
logging-data="722550"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lSZe273gZ473bmt8Ev4Cbq0I8byVg0a0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:xKiKsSbtLxenLQdrYHt2pB+RGxY=
In-Reply-To: <urq4fe$lapm$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 29 Feb 2024 15:30 UTC

On 29/02/2024 15:31, bart wrote:
> On 28/02/2024 21:36, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> AFAIK strings in C can have embedded zeros when not assumed to be
>>> zero-terminated. So here:
>>>
>>>      char s[]={1,2,3,0,4,5,6};
>>>
>>> s will have a length of 7.
>>
>> Strings *by definition* cannot have embedded zeros.  A null character
>> terminates a string.
>>
>> A string literal can have embedded \0 characters, but if you're
>> suggesting that #embed should expand to a string literal, I can see
>> several disadvantages and no significant advantages.  For one thing, the
>> data may or may not end with a null character; string literals always
>> do.
>
> Not here:
>
>     char s[]  = "ABC";

"ABC" is a "string literal". Once things like concatenation of adjacent
strings, macro expansion, etc., is complete, a null character is
appended to it. Then it is used as an initialiser for the array "s".
After initialisation, "s" is an array of 4 chars and contains a string.

(Note - a "string literal" might not be a "string", because string
literals can contain embedded nulls. This is a footnote in 6.4.5
describing string literals.)

>     char t[3] = "DEF";
>
> The "DEF" string doesn't end with a zero.

"DEF" is not a "string" - it is a "string literal". It does get a null
character appended during translation phase 7. But only the first three
characters - therefore not including the null character - get copied to
"t" during the initialisation of "t". "t" is an array of 3 chars, and
it does not contain a string.

>
> Is 'string' given a special meaning in the standard?
>

Yes. See 7.1.1p1.

> /That/ would seem to me to be too restrictive. Does this:
>
>    char *s;
>
> define a pointer to a such string, or can it be any kind of data? For
> example, `char*` is used by the GetOpenFileName WinAPI function for a
> /series/ of zero-terminated strings which itself is terminated with two
> zero bytes.
>

"char *s;" declares a pointer to a char, or a pointer to the start of an
array of char. It is /not/ a string, or a pointer to a string. C
strings are values, and exist at run-time - they are not types. So "s"
can point to a string, or a char (which will be a string if and only if
it is a null character), or an array of chars (which may or may not
contain a string), or it could point to anything else.

> So it is some property that is attributed to the data that will be stored.

Yes.

>
> I normally use `cstring` or `stringz` outside the language when refering
> to a zero-terminated sequences of characters, which implies that
> embedded zeros aren't allowed.
>

That makes sense. Different languages have different ways of holding
sequences of characters (generic "string" data), so you need to qualify
the term if it is not clear from the context.

But when we are discussing C, and there is no other qualification,
"string" means "C string" - the definition of "string" given in the C
standards.

Re: Implicit String-Literal Concatenation

<urq860$2ntv$2@news.gegeweb.eu>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33929&group=comp.lang.c#33929

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!.POSTED.2a01:cb19:8674:1100:216d:274a:f506:6cd1!not-for-mail
From: tth...@none.invalid (tTh)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 16:34:24 +0100
Organization: none
Message-ID: <urq860$2ntv$2@news.gegeweb.eu>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com> <urphlj$ejuu$1@dont-email.me>
<urpllc$ff02$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Feb 2024 15:34:24 -0000 (UTC)
Injection-Info: news.gegeweb.eu; posting-account="tontonth@usenet.local"; posting-host="2a01:cb19:8674:1100:216d:274a:f506:6cd1";
logging-data="90047"; mail-complaints-to="abuse@gegeweb.eu"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Cancel-Lock: sha256:l3xgi1uCOu2wMo8OEzKofhnbEkf523KAkeIUcp00igg=
In-Reply-To: <urpllc$ff02$1@dont-email.me>
 by: tTh - Thu, 29 Feb 2024 15:34 UTC

On 2/29/24 11:18, bart wrote:
> Using 'strinclude' in my old C compiler, it took about 1 second to build
> this program:
>
>   #include <stdio.h>
>   #include <string.h>
>
>   char* s=strinclude("data");
>
>   int main(void) {
>      printf("%zu\n", strlen(s));
>  }

tth@redlady:~/Desktop$ man strinclude
No manual entry for strinclude
tth@redlady:~/Desktop$

--
+---------------------------------------------------------------------+
| https://tube.interhacker.space/a/tth/video-channels |
+---------------------------------------------------------------------+

Re: Implicit String-Literal Concatenation

<DH1EN.511038$xHn7.241242@fx14.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33930&group=comp.lang.c#33930

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me> <urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me> <20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me> <uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me> <uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me>
Lines: 26
Message-ID: <DH1EN.511038$xHn7.241242@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 15:48:51 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 15:48:51 GMT
X-Received-Bytes: 1879
 by: Scott Lurndal - Thu, 29 Feb 2024 15:48 UTC

bart <bc@freeuk.com> writes:
>On 28/02/2024 23:52, Lawrence D'Oliveiro wrote:
>> On Wed, 28 Feb 2024 21:34:14 +0000, bart wrote:
>>
>>> In C:
>>>
>>> void Add(int CategoryCode, ItemType Item) {
>>> CodeToIndex_put(CategoryCode, getCount());
>>> add(Item);
>>> }
>>>
>>> 4 non-comment lines versus 9. I know Java needs tons of boilerplate, but
>>> but it is not all the language's fault.
>>
>> Or how about
>>
>> void Add(int CategoryCode, ItemType Item) {CodeToIndex_put(CategoryCode, getCount());add(Item);}
>>
>> Wow! I never realized you could do that in C!! I thought it was an
>> error to put stuff after column 72 or something. Thanks for the tip!!!
>
>Well, you could write an entire program on one line.

int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}

(A winner from the obfuscated C contest).

Re: Implicit String-Literal Concatenation

<AL1EN.511040$xHn7.220429@fx14.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33931&group=comp.lang.c#33931

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me>
Lines: 33
Message-ID: <AL1EN.511040$xHn7.220429@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 15:53:04 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 15:53:04 GMT
X-Received-Bytes: 2498
 by: Scott Lurndal - Thu, 29 Feb 2024 15:53 UTC

bart <bc@freeuk.com> writes:
>On 28/02/2024 23:31, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>
>>> It would be unfortunate if your example was allowed. Clearly a binary
>>> representation of an instance of your struct would probably require 16
>>> bytes rather than 4, of which one may be padding.
>>
>> Depending on the sizes and alignments of the various types, sure.
>> So what?
>>
>
>> If you have suggestions for alternate ways to define #embed, they might
>> be interesting, but it's too late to change the existing specification.
>>
>
>My early comments on this were about compiler performance. I suggested
>there might be a way to turn 100,000 byte values in a file, directly
>into a 100KB string or data block, without needing to first convert
>100,000 values into 100,000 integer expressions representated as tokens,
>and to then parse those 100,000 expressions into AST nodes etc.
>
>DB suggested something like that was actually done. But you can't do
>that if those 100,000 numbers represent from 100KB to 800KB of memory
>depending on the data type of the strucure they're initialising.

An implementation is free to simply pass a variant (or the directive
itself) of #embed from the pre-processor to the compiler if the programmer
isn't using -E, and the compiler could simply copy the embedded file
into the object file directly, without processing it as a series of
integer values. Much like the #file and #line directives passed by
the pre-processor to the compiler.

Re: Implicit String-Literal Concatenation

<urq9st$mfrd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33933&group=comp.lang.c#33933

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 17:03:41 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <urq9st$mfrd$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me>
<urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me>
<20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me>
<uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me>
<uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me>
<DH1EN.511038$xHn7.241242@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 16:03:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="94a97d4028fcafb8ea37198aa41da96c";
logging-data="737133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18p6GTep/x1ebMBBsl/heXY"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:4fYsGXpVJ9rLTK3FLPMTG+mXREc=
In-Reply-To: <DH1EN.511038$xHn7.241242@fx14.iad>
 by: Janis Papanagnou - Thu, 29 Feb 2024 16:03 UTC

On 29.02.2024 16:48, Scott Lurndal wrote:
>
> int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}

What does it do?

What preconditions must be fulfilled or what additions
does it need to compile?

>
> (A winner from the obfuscated C contest).

(Are non-compiling C sources allowed in the contest?)

Janis

Re: Implicit String-Literal Concatenation

<87msrjtfrc.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33934&group=comp.lang.c#33934

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 08:08:23 -0800
Organization: None to speak of
Lines: 26
Message-ID: <87msrjtfrc.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me>
<87frxcuv87.fsf@nosuchdomain.example.com>
<urprdv$gfvq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="733807"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yuwgxmhVGX6GeodgxTWwz"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:J0R3x/VGq+ar6UI3fwBfGY+Q5MA=
sha1:HkB6GI7KtKJ2n4g1fyGTLPg+yaE=
 by: Keith Thompson - Thu, 29 Feb 2024 16:08 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On 28/02/2024 21:36, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> AFAIK strings in C can have embedded zeros when not assumed to be
>>> zero-terminated. So here:
>>>
>>> char s[]={1,2,3,0,4,5,6};
>>>
>>> s will have a length of 7.
>> Strings *by definition* cannot have embedded zeros. A null
>> character
>> terminates a string.
>>
> C strings. Not strings in other programming languages. And only if you
> define "C strings" in a rather restrictive but, to be fair, totally
> legitimate way. So I wouldn't have put in the asterisks.

Yes, C strings. Or has we call them here in comp.lang.c, strings.

Sheesh.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<T42EN.21986$hN14.13629@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33935&group=comp.lang.c#33935

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me> <urq7sk$2ntv$1@news.gegeweb.eu>
Lines: 19
Message-ID: <T42EN.21986$hN14.13629@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 16:15:47 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 16:15:47 GMT
X-Received-Bytes: 1806
 by: Scott Lurndal - Thu, 29 Feb 2024 16:15 UTC

tTh <tth@none.invalid> writes:
>On 2/29/24 01:47, bart wrote:
>
>> My early comments on this were about compiler performance. I suggested
>> there might be a way to turn 100,000 byte values in a file, directly
>> into a 100KB string or data block, without needing to first convert
>> 100,000 values into 100,000 integer expressions representated as tokens,
>> and to then parse those 100,000 expressions into AST nodes etc.
>
> But you HAVE to do that il #embed is in the preprocessor,
> because his job is to give compilable text to the real
> compiler. No other way is possible.

The standard does not require the preprocessor to be
separate from a 'real' compiler. It's acceptable for an implementation
to implement both in a single executable. Absent -E, the
preprocessor and compiler can cooperate to efficiently handle
#embed without generating parseable C code.

Re: Implicit String-Literal Concatenation

<I62EN.21987$hN14.16206@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33936&group=comp.lang.c#33936

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me> <urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me> <20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me> <uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me> <uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me> <DH1EN.511038$xHn7.241242@fx14.iad> <urq9st$mfrd$1@dont-email.me>
Lines: 19
Message-ID: <I62EN.21987$hN14.16206@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 16:17:44 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 16:17:44 GMT
X-Received-Bytes: 1510
 by: Scott Lurndal - Thu, 29 Feb 2024 16:17 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>On 29.02.2024 16:48, Scott Lurndal wrote:
>>
>> int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}
>
>What does it do?
>
>What preconditions must be fulfilled or what additions
>does it need to compile?
>
>>
>> (A winner from the obfuscated C contest).
>
>(Are non-compiling C sources allowed in the contest?)

https://www.ioccc.org/years.html

The above is from 'burton'.

Re: Implicit String-Literal Concatenation

<87il27tf9v.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33937&group=comp.lang.c#33937

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 08:18:52 -0800
Organization: None to speak of
Lines: 54
Message-ID: <87il27tf9v.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me>
<87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="742972"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PWaXZ/Uguc53mJiKzdGCX"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:wF6Ix9626bka/Q3e4+Z89jMkFns=
sha1:I6sQQYRMuGsfTn+EiMssY/OQcjY=
 by: Keith Thompson - Thu, 29 Feb 2024 16:18 UTC

bart <bc@freeuk.com> writes:
> On 28/02/2024 21:36, Keith Thompson wrote:
>> bart <bc@freeuk.com> writes:
>> [...]
>>> AFAIK strings in C can have embedded zeros when not assumed to be
>>> zero-terminated. So here:
>>>
>>> char s[]={1,2,3,0,4,5,6};
>>>
>>> s will have a length of 7.
>> Strings *by definition* cannot have embedded zeros. A null
>> character
>> terminates a string.
>> A string literal can have embedded \0 characters, but if you're
>> suggesting that #embed should expand to a string literal, I can see
>> several disadvantages and no significant advantages. For one thing, the
>> data may or may not end with a null character; string literals always
>> do.
>
> Not here:
>
> char s[] = "ABC";
> char t[3] = "DEF";
>
> The "DEF" string doesn't end with a zero.

That's not strictly true, nor is it relevant.

For #embed, you generally don't know the length of the resulting
sequence of values, so you can't usually write something like:

const unsigned char data[N] = {
#embed "foo.dat"
};

And the way it's described in the standard is that "DEF" refers to an
array object that does include a trailing null byte, but only the first
3 characters are used to initialize t. Of course a compiler can
optimize that one byte away.

> Is 'string' given a special meaning in the standard?

Of course it is. Surely you know that. 7.1.1 paragraph 1.

"abc\0def" is a valid string literal, but its value is not a string.
(No, the standard doesn't say that the value of a string literal is a
string.)

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<87edcvtez4.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33938&group=comp.lang.c#33938

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 08:25:19 -0800
Organization: None to speak of
Lines: 29
Message-ID: <87edcvtez4.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me>
<87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me> <urq7tu$m1jm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="742972"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1915+Qcsi1Zx93JxgzoZ0aD"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Zb4DdVHcseh22jl99yO4SSzKIsg=
sha1:MhJac9ZmHy5M/yS3M+Vgu2Zup4k=
 by: Keith Thompson - Thu, 29 Feb 2024 16:25 UTC

David Brown <david.brown@hesbynett.no> writes:
[...]
> "char *s;" declares a pointer to a char, or a pointer to the start of
> an array of char.

"char *s;" defines a pointer to char. At runtime, it may or may not
point to the initial element of an array object. (And for most
purposes, a char object is treated as 1-element array of char.)

> It is /not/ a string, or a pointer to a string.

It may be a pointer to a string at run time, depending on what it
currently points to.

> C strings are values, and exist at run-time - they are not types. So
> "s" can point to a string, or a char (which will be a string if and
> only if it is a null character), or an array of chars (which may or
> may not contain a string), or it could point to anything else.

"s" can point to *the initial element of* an array of chars. if that
array contains a string, then (the value of) s is by definition a
pointer to a string.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<87a5njtd72.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33939&group=comp.lang.c#33939

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 09:03:45 -0800
Organization: None to speak of
Lines: 117
Message-ID: <87a5njtd72.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com>
<urphlj$ejuu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="762065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BF2xbSIZmRgkho3gEyDZR"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:aD5qRTfZ9P/WtChWua3ftD5anSg=
sha1:d8YWI9zXaffBPyzGDCPY0A/UHuE=
 by: Keith Thompson - Thu, 29 Feb 2024 17:03 UTC

David Brown <david.brown@hesbynett.no> writes:
> On 28/02/2024 22:57, Keith Thompson wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>> [...]
>>> They won't use strings, they will use data blobs - binary data. Then
>>> there is no issue with null bytes. And yes, implementations will skip
>>> the token generation (unless you are doing something weird, such as
>>> using #embed to read the parameters to a function call).
>>>
>>> Tests with prototype implementations gave extremely fast results.
>> I'm not sure how that would work. #embed is a preprocessor
>> directive,
>> and at least in the abstract model it has to expand to valid C code.
>> I would have expected that it would simply generate the list of
>> comma-separated integer constants described in the standard; later
>> phases would simply parse that list and generate code as if that
>> sequence had been written in the original source file. Do you know of
>> an implementation that does something else?
>
> The key thing, as I understand it, is that the compiler gets to know
> that the integers in the list are all "nice". And since the
> preprocessor and the compiler are part of the same implementation
> (even if they are separate programs communicating with pipes or
> temporary files), the preprocessor could pass on the binary blob in a
> pre-parsed form.
[...]

Sure, an implementation *could* optimize #embed so it expands to some
implementation-defined nonstandard form that later phases can treat as
raw data. But since it's defined as a preprocessor directive, it's
difficult to see how it could do so while covering all cases.

[...]

> The results of testing are that #embed is /massively/ faster and lower
> memory compared to external generators, especially for larger files.
> And it gives you the data on-hand for optimisation purposes, unlike
> external direct linking of binary blobs. (So you can get the size of
> the array, or use values from it as compile-time known values.)

What testing? The very latest versions of gcc and clang (I checked both
their git repos yesterday) do not yet implement #embed.

>> For example, say you have a file "foo.dat" containing 4 bytes with
>> values 0, 1, 2, and 3. This would be perfectly valid:
>> struct foo {
>> unsigned char a;
>> unsigned short b;
>> unsigned int c;
>> double d;
>> };
>> struct foo obj = {
>> #embed "foo.dat"
>> };
>> #embed isn't defined to translate an input file to a sequence of
>> bytes.
>> It's defined to translate an input file to a sequence of integer
>> constant expressions.
>
> Yes. But the prime speed (and memory usage) gains come in, are for
> large files, and that means array initialisers. That does not
> conflict with using it for cases like yours.

So a compiler that does this would have to be able to handle

struct foo obj = {
#blob
<binary data>
#endblob>
};

and initialize a, b, c, and d to 0, 1, 2, and 3.0, respectively from
successive bytes of the binary data. Either that, or the preprocessor
would have to use information it doesn't have to determine how to expand
#embed.

>> *Maybe* a compiler could optimize for the case where it knows that it's
>> being used to initialize an array of unsigned char, but (a) that would
>> require the preprocessor to have information that normally doesn't exist
>> until later phases, and (b) I'm not convinced it would be worth the
>> effort.
>
> Look at
> <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1040r6.html#design-practice-speed>.
>
> In those tests, for a 40 MB file gcc #embed is 200 times faster than
> "xxd -i" generated files, and takes about 2.5% of the memory. It
> scales to 1 GB files. And that's just a proof-of-concept
> implementation.

That's for std::embed, a proposed C++ feature that's *not* defined as a
preprocessor directive. Sample usage from the paper:

constexpr std::span<const std::byte> fxaa_binary =
std::embed( "fxaa.spirv" );

So the compiler knows the type of the object being initialized.

(Note that the author of that C++ paper is also the editor for the C
standard.)

I'm still skeptical that C's #embed will actually be implemented other
than as expanding to a sequence of integer constants.

On the other hand, C23 allows for additional implementation-defined
parameters to #embed (as well as the standard embed parameters limit,
prefix, suffix, and is_empty). Such a parameter could specify how it's
expanded, perhaps to some implementation-defined blob format. *If*
compilers optimize #embed to something other than a sequence of integer
constant expressions, that's probably how it would be done. But since
neither gcc nor clang implements #embed at all, it may be too early to
speculate.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<875xy7td2o.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33940&group=comp.lang.c#33940

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 09:06:23 -0800
Organization: None to speak of
Lines: 43
Message-ID: <875xy7td2o.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com>
<uroe02$4eoh$1@dont-email.me>
<87y1b4tbcq.fsf@nosuchdomain.example.com>
<urok6t$5lv4$1@dont-email.me> <AL1EN.511040$xHn7.220429@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="762065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zOulwklQoRovpR9aQiH+S"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:2OXkWJaQgEmgA8m/uWXerVCROpg=
sha1:o3Ci8MVLwZ14LcfFnUku5egitW0=
 by: Keith Thompson - Thu, 29 Feb 2024 17:06 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> bart <bc@freeuk.com> writes:
>>On 28/02/2024 23:31, Keith Thompson wrote:
>>> bart <bc@freeuk.com> writes:
>>
>>>> It would be unfortunate if your example was allowed. Clearly a binary
>>>> representation of an instance of your struct would probably require 16
>>>> bytes rather than 4, of which one may be padding.
>>>
>>> Depending on the sizes and alignments of the various types, sure.
>>> So what?
>>>
>>
>>> If you have suggestions for alternate ways to define #embed, they might
>>> be interesting, but it's too late to change the existing specification.
>>>
>>
>>My early comments on this were about compiler performance. I suggested
>>there might be a way to turn 100,000 byte values in a file, directly
>>into a 100KB string or data block, without needing to first convert
>>100,000 values into 100,000 integer expressions representated as tokens,
>>and to then parse those 100,000 expressions into AST nodes etc.
>>
>>DB suggested something like that was actually done. But you can't do
>>that if those 100,000 numbers represent from 100KB to 800KB of memory
>>depending on the data type of the strucure they're initialising.
>
> An implementation is free to simply pass a variant (or the directive
> itself) of #embed from the pre-processor to the compiler if the programmer
> isn't using -E, and the compiler could simply copy the embedded file
> into the object file directly, without processing it as a series of
> integer values. Much like the #file and #line directives passed by
> the pre-processor to the compiler.

Sure, an implementation has to operate *as if* it implemented the 8
translation phases separately. But given a structure initialized with
#embed, it would have to generate additional code to initialize the
structure members from the bytes of the binary blob.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<urqdtl$nbj3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33941&group=comp.lang.c#33941

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 18:12:20 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <urqdtl$nbj3$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me>
<urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me>
<20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me>
<uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me>
<uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me>
<DH1EN.511038$xHn7.241242@fx14.iad> <urq9st$mfrd$1@dont-email.me>
<I62EN.21987$hN14.16206@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 17:12:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="94a97d4028fcafb8ea37198aa41da96c";
logging-data="765539"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18G5t+8iKRDvRvrzBJaVKBI"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:fmf5YoIIBnoc0XiQl8xEQ8WMKTE=
In-Reply-To: <I62EN.21987$hN14.16206@fx17.iad>
 by: Janis Papanagnou - Thu, 29 Feb 2024 17:12 UTC

On 29.02.2024 17:17, Scott Lurndal wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 29.02.2024 16:48, Scott Lurndal wrote:
>>>
>>> int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}
>>
>> What does it do?
>>
>> What preconditions must be fulfilled or what additions
>> does it need to compile?

With the link below I see it "needs" a 600+ lines long Makefile.

And I see there's some variable definitions with magic numbers
passed.

>>
>>>
>>> (A winner from the obfuscated C contest).
>>
>> (Are non-compiling C sources allowed in the contest?)
>
> https://www.ioccc.org/years.html
>
> The above is from 'burton'.

Thanks.

Janis

Re: Implicit String-Literal Concatenation

<urqe71$ndb4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33942&group=comp.lang.c#33942

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 18:17:19 +0100
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <urqe71$ndb4$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me> <87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me> <87il27tf9v.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 17:17:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6585c110415aecacdf06b444dafb3632";
logging-data="767332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vNcaUnQZb8cXmQnsB1inh"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6dKYG8nAAX9+AutVRNUhqwuaMVk=
In-Reply-To: <87il27tf9v.fsf@nosuchdomain.example.com>
 by: Janis Papanagnou - Thu, 29 Feb 2024 17:17 UTC

On 29.02.2024 17:18, Keith Thompson wrote:
>
> "abc\0def" is a valid string literal, but its value is not a string.
> (No, the standard doesn't say that the value of a string literal is a
> string.)

This sounds somewhat strange in my ears. Usually a literal for a type
will constitute an instance of the type. - I suppose the irregularity
stems from the fact that there's no explicit string object type in C.

Janis

Re: Implicit String-Literal Concatenation

<871q8vtcfh.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33943&group=comp.lang.c#33943

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 09:20:18 -0800
Organization: None to speak of
Lines: 31
Message-ID: <871q8vtcfh.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me>
<urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me>
<20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me>
<uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me>
<uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me>
<DH1EN.511038$xHn7.241242@fx14.iad> <urq9st$mfrd$1@dont-email.me>
<I62EN.21987$hN14.16206@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="762065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183H6wv/cNltLVFtG3Ua+jq"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:zc9cr5edsS6GU6a5HwkdbLJl+LY=
sha1:SA6QyyEbRJZnyiCx4MvK2FoJ/GQ=
 by: Keith Thompson - Thu, 29 Feb 2024 17:20 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>>On 29.02.2024 16:48, Scott Lurndal wrote:
>>>
>>> int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}
>>
>>What does it do?
>>
>>What preconditions must be fulfilled or what additions
>>does it need to compile?
>>
>>>
>>> (A winner from the obfuscated C contest).
>>
>>(Are non-compiling C sources allowed in the contest?)
>
> https://www.ioccc.org/years.html
>
> The above is from 'burton'.

"burton" has submitted a number of entries over the years. This one is
https://www.ioccc.org/2020/burton/index.html

The program by itself does not compile. The provided Makefile passes
additional arguments, with B and I being defined differently in
big-endian vs. little-endian machines.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<87wmqnrxrf.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33944&group=comp.lang.c#33944

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 09:22:28 -0800
Organization: None to speak of
Lines: 16
Message-ID: <87wmqnrxrf.fsf@nosuchdomain.example.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me>
<87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me>
<87il27tf9v.fsf@nosuchdomain.example.com>
<urqe71$ndb4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2beb5206cb1be4986a7eae51046cf684";
logging-data="762065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pbB+EKwGNUM8WpR915h7S"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:3mq/oZnc3KPwmumr2NUBUHxAwJQ=
sha1:hYqb21XQk8fCHIUofLYYaVJ5QiU=
 by: Keith Thompson - Thu, 29 Feb 2024 17:22 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 29.02.2024 17:18, Keith Thompson wrote:
>> "abc\0def" is a valid string literal, but its value is not a string.
>> (No, the standard doesn't say that the value of a string literal is a
>> string.)
>
> This sounds somewhat strange in my ears. Usually a literal for a type
> will constitute an instance of the type. - I suppose the irregularity
> stems from the fact that there's no explicit string object type in C.

Exactly, "string" is not a type.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Implicit String-Literal Concatenation

<593EN.22560$zF_1.19152@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33945&group=comp.lang.c#33945

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me> <AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com>
Lines: 43
Message-ID: <593EN.22560$zF_1.19152@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 17:28:33 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 17:28:33 GMT
X-Received-Bytes: 3215
 by: Scott Lurndal - Thu, 29 Feb 2024 17:28 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>scott@slp53.sl.home (Scott Lurndal) writes:
>> bart <bc@freeuk.com> writes:
>>>On 28/02/2024 23:31, Keith Thompson wrote:
>>>> bart <bc@freeuk.com> writes:
>>>
>>>>> It would be unfortunate if your example was allowed. Clearly a binary
>>>>> representation of an instance of your struct would probably require 16
>>>>> bytes rather than 4, of which one may be padding.
>>>>
>>>> Depending on the sizes and alignments of the various types, sure.
>>>> So what?
>>>>
>>>
>>>> If you have suggestions for alternate ways to define #embed, they might
>>>> be interesting, but it's too late to change the existing specification.
>>>>
>>>
>>>My early comments on this were about compiler performance. I suggested
>>>there might be a way to turn 100,000 byte values in a file, directly
>>>into a 100KB string or data block, without needing to first convert
>>>100,000 values into 100,000 integer expressions representated as tokens,
>>>and to then parse those 100,000 expressions into AST nodes etc.
>>>
>>>DB suggested something like that was actually done. But you can't do
>>>that if those 100,000 numbers represent from 100KB to 800KB of memory
>>>depending on the data type of the strucure they're initialising.
>>
>> An implementation is free to simply pass a variant (or the directive
>> itself) of #embed from the pre-processor to the compiler if the programmer
>> isn't using -E, and the compiler could simply copy the embedded file
>> into the object file directly, without processing it as a series of
>> integer values. Much like the #file and #line directives passed by
>> the pre-processor to the compiler.
>
>Sure, an implementation has to operate *as if* it implemented the 8
>translation phases separately. But given a structure initialized with
>#embed, it would have to generate additional code to initialize the
>structure members from the bytes of the binary blob.

Would it? Or could it simply assume that the binary blob
is already in the same binary format that writing an instance
of the structure from a C application on the same host would have created?

Re: Implicit String-Literal Concatenation

<sa3EN.22761$zF_1.16954@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33946&group=comp.lang.c#33946

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlb8p$3bvbc$1@dont-email.me> <urln99$3ejjt$1@dont-email.me> <urlp3h$3ep9p$5@dont-email.me> <20240227170925.837@kylheku.com> <urn6li$3s62i$1@dont-email.me> <uro6ls$2mh1$5@dont-email.me> <uro8sl$3d71$1@dont-email.me> <uroh0n$51an$2@dont-email.me> <uroial$58n9$1@dont-email.me> <DH1EN.511038$xHn7.241242@fx14.iad> <urq9st$mfrd$1@dont-email.me> <I62EN.21987$hN14.16206@fx17.iad> <urqdtl$nbj3$1@dont-email.me>
Lines: 16
Message-ID: <sa3EN.22761$zF_1.16954@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 17:30:00 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 17:30:00 GMT
X-Received-Bytes: 1643
 by: Scott Lurndal - Thu, 29 Feb 2024 17:30 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>On 29.02.2024 17:17, Scott Lurndal wrote:
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>>> On 29.02.2024 16:48, Scott Lurndal wrote:
>>>>
>>>> int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}
>>>
>>> What does it do?
>>>
>>> What preconditions must be fulfilled or what additions
>>> does it need to compile?
>
>With the link below I see it "needs" a 600+ lines long Makefile.

The readme simply says compile it and run it
as ./prog <value between 1 and 512>.

Re: Implicit String-Literal Concatenation

<urqgkq$nt9f$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33947&group=comp.lang.c#33947

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 18:58:49 +0100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <urqgkq$nt9f$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me>
<87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me>
<AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com>
<593EN.22560$zF_1.19152@fx18.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 17:58:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f99e7338f93fdbe8ddcb741f55a4912";
logging-data="783663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3iK1SD8LNpBfsolioDXe5Z2geicLWKLk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:c5iZc6Usm3nfRwxuV2OwHyrtXK0=
In-Reply-To: <593EN.22560$zF_1.19152@fx18.iad>
Content-Language: en-GB
 by: David Brown - Thu, 29 Feb 2024 17:58 UTC

On 29/02/2024 18:28, Scott Lurndal wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> scott@slp53.sl.home (Scott Lurndal) writes:
>>> bart <bc@freeuk.com> writes:
>>>> On 28/02/2024 23:31, Keith Thompson wrote:
>>>>> bart <bc@freeuk.com> writes:
>>>>
>>>>>> It would be unfortunate if your example was allowed. Clearly a binary
>>>>>> representation of an instance of your struct would probably require 16
>>>>>> bytes rather than 4, of which one may be padding.
>>>>>
>>>>> Depending on the sizes and alignments of the various types, sure.
>>>>> So what?
>>>>>
>>>>
>>>>> If you have suggestions for alternate ways to define #embed, they might
>>>>> be interesting, but it's too late to change the existing specification.
>>>>>
>>>>
>>>> My early comments on this were about compiler performance. I suggested
>>>> there might be a way to turn 100,000 byte values in a file, directly
>>>> into a 100KB string or data block, without needing to first convert
>>>> 100,000 values into 100,000 integer expressions representated as tokens,
>>>> and to then parse those 100,000 expressions into AST nodes etc.
>>>>
>>>> DB suggested something like that was actually done. But you can't do
>>>> that if those 100,000 numbers represent from 100KB to 800KB of memory
>>>> depending on the data type of the strucure they're initialising.
>>>
>>> An implementation is free to simply pass a variant (or the directive
>>> itself) of #embed from the pre-processor to the compiler if the programmer
>>> isn't using -E, and the compiler could simply copy the embedded file
>>> into the object file directly, without processing it as a series of
>>> integer values. Much like the #file and #line directives passed by
>>> the pre-processor to the compiler.
>>
>> Sure, an implementation has to operate *as if* it implemented the 8
>> translation phases separately. But given a structure initialized with
>> #embed, it would have to generate additional code to initialize the
>> structure members from the bytes of the binary blob.
>
> Would it? Or could it simply assume that the binary blob
> is already in the same binary format that writing an instance
> of the structure from a C application on the same host would have created?

That would depend on the sizes of the fields in the struct, and the size
of the integer constants in the #embed. The norm for #embed will be
unsigned char integer constants, so it will only be a direct fit for the
binary representation of the struct if all the struct fields are
compatible with that. But a compiler could have vendor parameters on
the #embed to change those sizes.

Re: Implicit String-Literal Concatenation

<2I3EN.637365$p%Mb.40952@fx15.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33948&group=comp.lang.c#33948

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me> <AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com> <593EN.22560$zF_1.19152@fx18.iad> <urqgkq$nt9f$1@dont-email.me>
Lines: 53
Message-ID: <2I3EN.637365$p%Mb.40952@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 18:05:50 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 18:05:50 GMT
X-Received-Bytes: 3725
 by: Scott Lurndal - Thu, 29 Feb 2024 18:05 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 29/02/2024 18:28, Scott Lurndal wrote:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> scott@slp53.sl.home (Scott Lurndal) writes:
>>>> bart <bc@freeuk.com> writes:
>>>>> On 28/02/2024 23:31, Keith Thompson wrote:
>>>>>> bart <bc@freeuk.com> writes:
>>>>>
>>>>>>> It would be unfortunate if your example was allowed. Clearly a binary
>>>>>>> representation of an instance of your struct would probably require 16
>>>>>>> bytes rather than 4, of which one may be padding.
>>>>>>
>>>>>> Depending on the sizes and alignments of the various types, sure.
>>>>>> So what?
>>>>>>
>>>>>
>>>>>> If you have suggestions for alternate ways to define #embed, they might
>>>>>> be interesting, but it's too late to change the existing specification.
>>>>>>
>>>>>
>>>>> My early comments on this were about compiler performance. I suggested
>>>>> there might be a way to turn 100,000 byte values in a file, directly
>>>>> into a 100KB string or data block, without needing to first convert
>>>>> 100,000 values into 100,000 integer expressions representated as tokens,
>>>>> and to then parse those 100,000 expressions into AST nodes etc.
>>>>>
>>>>> DB suggested something like that was actually done. But you can't do
>>>>> that if those 100,000 numbers represent from 100KB to 800KB of memory
>>>>> depending on the data type of the strucure they're initialising.
>>>>
>>>> An implementation is free to simply pass a variant (or the directive
>>>> itself) of #embed from the pre-processor to the compiler if the programmer
>>>> isn't using -E, and the compiler could simply copy the embedded file
>>>> into the object file directly, without processing it as a series of
>>>> integer values. Much like the #file and #line directives passed by
>>>> the pre-processor to the compiler.
>>>
>>> Sure, an implementation has to operate *as if* it implemented the 8
>>> translation phases separately. But given a structure initialized with
>>> #embed, it would have to generate additional code to initialize the
>>> structure members from the bytes of the binary blob.
>>
>> Would it? Or could it simply assume that the binary blob
>> is already in the same binary format that writing an instance
>> of the structure from a C application on the same host would have created?
>
>That would depend on the sizes of the fields in the struct, and the size
>of the integer constants in the #embed.

I'm embedding a binary file. I want the representation in memory
to be _exactly_ the same as in the file, regardless of how it is
defined in the C code (array of char, array of int, array of long, struct whatever).

Re: Implicit String-Literal Concatenation

<urqh6m$nt9f$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33949&group=comp.lang.c#33949

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 19:08:22 +0100
Organization: A noiseless patient Spider
Lines: 146
Message-ID: <urqh6m$nt9f$2@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com> <urphlj$ejuu$1@dont-email.me>
<87a5njtd72.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 18:08:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5f99e7338f93fdbe8ddcb741f55a4912";
logging-data="783663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HjGPFaiL/o7LwtUGA05kIdfefY6n/9xk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:tcJot40mTzYvl6jjQ99lthiiFaQ=
In-Reply-To: <87a5njtd72.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Thu, 29 Feb 2024 18:08 UTC

On 29/02/2024 18:03, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 28/02/2024 22:57, Keith Thompson wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>> [...]
>>>> They won't use strings, they will use data blobs - binary data. Then
>>>> there is no issue with null bytes. And yes, implementations will skip
>>>> the token generation (unless you are doing something weird, such as
>>>> using #embed to read the parameters to a function call).
>>>>
>>>> Tests with prototype implementations gave extremely fast results.
>>> I'm not sure how that would work. #embed is a preprocessor
>>> directive,
>>> and at least in the abstract model it has to expand to valid C code.
>>> I would have expected that it would simply generate the list of
>>> comma-separated integer constants described in the standard; later
>>> phases would simply parse that list and generate code as if that
>>> sequence had been written in the original source file. Do you know of
>>> an implementation that does something else?
>>
>> The key thing, as I understand it, is that the compiler gets to know
>> that the integers in the list are all "nice". And since the
>> preprocessor and the compiler are part of the same implementation
>> (even if they are separate programs communicating with pipes or
>> temporary files), the preprocessor could pass on the binary blob in a
>> pre-parsed form.
> [...]
>
> Sure, an implementation *could* optimize #embed so it expands to some
> implementation-defined nonstandard form that later phases can treat as
> raw data. But since it's defined as a preprocessor directive, it's
> difficult to see how it could do so while covering all cases.
>

It would require a strong link between the compiler and the preprocessor
- as you know, these don't have to be separate programs. In a more
weakly coupled system, there could still be a method for passing a
binary blob to the compiler in addition to the integer data, and let the
compiler use whichever form it preferred (based on what your code does
with the data).

> [...]
>
>> The results of testing are that #embed is /massively/ faster and lower
>> memory compared to external generators, especially for larger files.
>> And it gives you the data on-hand for optimisation purposes, unlike
>> external direct linking of binary blobs. (So you can get the size of
>> the array, or use values from it as compile-time known values.)
>
> What testing? The very latest versions of gcc and clang (I checked both
> their git repos yesterday) do not yet implement #embed.
>

I believe prototypes, tests, or proofs of concept have been made for
gcc, clang and perhaps other tools. I posted a link to some results -
more are floating around the internet if you want to look for them.

>>> For example, say you have a file "foo.dat" containing 4 bytes with
>>> values 0, 1, 2, and 3. This would be perfectly valid:
>>> struct foo {
>>> unsigned char a;
>>> unsigned short b;
>>> unsigned int c;
>>> double d;
>>> };
>>> struct foo obj = {
>>> #embed "foo.dat"
>>> };
>>> #embed isn't defined to translate an input file to a sequence of
>>> bytes.
>>> It's defined to translate an input file to a sequence of integer
>>> constant expressions.
>>
>> Yes. But the prime speed (and memory usage) gains come in, are for
>> large files, and that means array initialisers. That does not
>> conflict with using it for cases like yours.
>
> So a compiler that does this would have to be able to handle
>
> struct foo obj = {
> #blob
> <binary data>
> #endblob>
> };
>
> and initialize a, b, c, and d to 0, 1, 2, and 3.0, respectively from
> successive bytes of the binary data. Either that, or the preprocessor
> would have to use information it doesn't have to determine how to expand
> #embed.
>

I think I've covered how that could be handled. (And I don't know how
it /will/ be handled. But I am sure compiler implementers will figure a
way to make it work correctly for any use of the integer constant list,
while also making it as efficient as they reasonably can for the common
case of initialising an unsigned char array.)

>>> *Maybe* a compiler could optimize for the case where it knows that it's
>>> being used to initialize an array of unsigned char, but (a) that would
>>> require the preprocessor to have information that normally doesn't exist
>>> until later phases, and (b) I'm not convinced it would be worth the
>>> effort.
>>
>> Look at
>> <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1040r6.html#design-practice-speed>.
>>
>> In those tests, for a 40 MB file gcc #embed is 200 times faster than
>> "xxd -i" generated files, and takes about 2.5% of the memory. It
>> scales to 1 GB files. And that's just a proof-of-concept
>> implementation.
>
> That's for std::embed, a proposed C++ feature that's *not* defined as a
> preprocessor directive. Sample usage from the paper:
>
> constexpr std::span<const std::byte> fxaa_binary =
> std::embed( "fxaa.spirv" );
>
> So the compiler knows the type of the object being initialized.
>
> (Note that the author of that C++ paper is also the editor for the C
> standard.)

The work on #embed is being done simultaneously for C and C++.
std::embed() gives you slightly different way to write it, but the
implementation is the same. (Not unlike _Pragma and #pragma in C.)

Other pages I have seen with speed tests show the same pattern while
referring explicitly to #embed.

>
> I'm still skeptical that C's #embed will actually be implemented other
> than as expanding to a sequence of integer constants.
>

We'll see when it all hits the mainline compilers!

> On the other hand, C23 allows for additional implementation-defined
> parameters to #embed (as well as the standard embed parameters limit,
> prefix, suffix, and is_empty). Such a parameter could specify how it's
> expanded, perhaps to some implementation-defined blob format. *If*
> compilers optimize #embed to something other than a sequence of integer
> constant expressions, that's probably how it would be done. But since
> neither gcc nor clang implements #embed at all, it may be too early to
> speculate.
>

Re: Implicit String-Literal Concatenation

<QL3EN.637366$p%Mb.580728@fx15.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33950&group=comp.lang.c#33950

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Implicit String-Literal Concatenation
Newsgroups: comp.lang.c
References: <urdsob$1e8e4$7@dont-email.me> <urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me> <urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me> <877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me> <87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me> <AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com> <593EN.22560$zF_1.19152@fx18.iad> <urqgkq$nt9f$1@dont-email.me> <2I3EN.637365$p%Mb.40952@fx15.iad>
Lines: 34
Message-ID: <QL3EN.637366$p%Mb.580728@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Feb 2024 18:09:52 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Feb 2024 18:09:52 GMT
X-Received-Bytes: 2748
 by: Scott Lurndal - Thu, 29 Feb 2024 18:09 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
>David Brown <david.brown@hesbynett.no> writes:
>>On 29/02/2024 18:28, Scott Lurndal wrote:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> scott@slp53.sl.home (Scott Lurndal) writes:

>>>>> An implementation is free to simply pass a variant (or the directive
>>>>> itself) of #embed from the pre-processor to the compiler if the programmer
>>>>> isn't using -E, and the compiler could simply copy the embedded file
>>>>> into the object file directly, without processing it as a series of
>>>>> integer values. Much like the #file and #line directives passed by
>>>>> the pre-processor to the compiler.
>>>>
>>>> Sure, an implementation has to operate *as if* it implemented the 8
>>>> translation phases separately. But given a structure initialized with
>>>> #embed, it would have to generate additional code to initialize the
>>>> structure members from the bytes of the binary blob.
>>>
>>> Would it? Or could it simply assume that the binary blob
>>> is already in the same binary format that writing an instance
>>> of the structure from a C application on the same host would have created?
>>
>>That would depend on the sizes of the fields in the struct, and the size
>>of the integer constants in the #embed.
>
>I'm embedding a binary file. I want the representation in memory
>to be _exactly_ the same as in the file, regardless of how it is
>defined in the C code (array of char, array of int, array of long, struct whatever).
>

I have an actual use case today where #embed of a (C++) std::map binary
object created by separate tool would be very useful. I'm
planning on using mmap to load it at runtime at the moment.

Re: Implicit String-Literal Concatenation

<20240229110522.422@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33952&group=comp.lang.c#33952

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 19:26:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240229110522.422@kylheku.com>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me> <87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me> <87il27tf9v.fsf@nosuchdomain.example.com>
<urqe71$ndb4$1@dont-email.me> <87wmqnrxrf.fsf@nosuchdomain.example.com>
Injection-Date: Thu, 29 Feb 2024 19:26:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="908c78747f4f323261e70259b5707610";
logging-data="820608"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r+2hug0XzJKi2lPPSiPxWVcDDMMouN70="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:cs43gjgUV+STomITWEdK1QzXetw=
 by: Kaz Kylheku - Thu, 29 Feb 2024 19:26 UTC

On 2024-02-29, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 29.02.2024 17:18, Keith Thompson wrote:
>>> "abc\0def" is a valid string literal, but its value is not a string.
>>> (No, the standard doesn't say that the value of a string literal is a
>>> string.)
>>
>> This sounds somewhat strange in my ears. Usually a literal for a type
>> will constitute an instance of the type. - I suppose the irregularity
>> stems from the fact that there's no explicit string object type in C.
>
> Exactly, "string" is not a type.

It is a type in the broader sense, in that is a logical proposition
about the attributes of an object that is true or false.

It's just not a type in the C static type system.

What that means is that there does not exist a constraint rule in
standard C requiring some expression or object to conform to the string
type. The concept "string" is not represented in the constraint system.
But it is a type concept.

(There are rules that require a string, but they are not constraint
rules. E.g. if strlen is given an argument which isn't a string, the
behavior is undefined.)

Consider:
char a[3] = "abc";
size_t l = strlen(a);

In the unlikely event that this example would capture the attention of a
computer scientist who researches type systems, he or she would identify
that as having a type error. (One that the C type system is too weak to
model.)

"Upper case letter" is also a type; that's why the header is called
<ctype.h>.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Implicit String-Literal Concatenation

<urqmt8$p3s4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33953&group=comp.lang.c#33953

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 14:45:44 -0500
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <urqmt8$p3s4$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<urnbh6$3t14d$1@dont-email.me> <87frxcuv87.fsf@nosuchdomain.example.com>
<urq4fe$lapm$1@dont-email.me> <87il27tf9v.fsf@nosuchdomain.example.com>
<urqe71$ndb4$1@dont-email.me> <87wmqnrxrf.fsf@nosuchdomain.example.com>
<20240229110522.422@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 19:45:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="aeb2a9ffad590efc6221007f6cd35596";
logging-data="823172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+MK7t26dTIsSbBUlND5EfZcbQ8HiQ0a0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:TNOtXWKYqvIwRaCflX7m62mCcu0=
In-Reply-To: <20240229110522.422@kylheku.com>
Content-Language: en-US
 by: James Kuyper - Thu, 29 Feb 2024 19:45 UTC

On 2/29/24 14:26, Kaz Kylheku wrote:
> On 2024-02-29, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
....>> Exactly, "string" is not a type.
>
> It is a type in the broader sense, in that is a logical proposition
> about the attributes of an object that is true or false.

If I defined something to be a sequence of floating point numbers
terminated by a NaN, would that thing also qualify as a type, according
to the definition you're using?

Could you give a source for the definition of "type" that you're using?
Can you use the word "type" in a statement whose truth relies upon the
difference between that definition and the way that "type" is defined by
the C standard? Preferably it would be a useful statement that applies to C.

Re: Implicit String-Literal Concatenation

<urqn7f$p9ki$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33954&group=comp.lang.c#33954

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Implicit String-Literal Concatenation
Date: Thu, 29 Feb 2024 20:51:11 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <urqn7f$p9ki$1@dont-email.me>
References: <urdsob$1e8e4$7@dont-email.me> <urj1qv$2p32o$1@dont-email.me>
<urk6um$33nqv$1@dont-email.me> <urlgfn$3d1ah$3@dont-email.me>
<urlmo7$3eg2j$1@dont-email.me> <urn6sv$3s62i$2@dont-email.me>
<877ciouua2.fsf@nosuchdomain.example.com> <uroe02$4eoh$1@dont-email.me>
<87y1b4tbcq.fsf@nosuchdomain.example.com> <urok6t$5lv4$1@dont-email.me>
<AL1EN.511040$xHn7.220429@fx14.iad> <875xy7td2o.fsf@nosuchdomain.example.com>
<593EN.22560$zF_1.19152@fx18.iad> <urqgkq$nt9f$1@dont-email.me>
<2I3EN.637365$p%Mb.40952@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Feb 2024 19:51:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="964bb6b5968ed1b847970efe2c01347e";
logging-data="829074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oGcj18V7jaIhUKfVvWXKd6mqTWsVLMbg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:YZvmA6gV1lWtuu7Bafi0qOpdOyc=
Content-Language: en-GB
In-Reply-To: <2I3EN.637365$p%Mb.40952@fx15.iad>
 by: David Brown - Thu, 29 Feb 2024 19:51 UTC

On 29/02/2024 19:05, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 29/02/2024 18:28, Scott Lurndal wrote:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> scott@slp53.sl.home (Scott Lurndal) writes:
>>>>> bart <bc@freeuk.com> writes:
>>>>>> On 28/02/2024 23:31, Keith Thompson wrote:
>>>>>>> bart <bc@freeuk.com> writes:
>>>>>>
>>>>>>>> It would be unfortunate if your example was allowed. Clearly a binary
>>>>>>>> representation of an instance of your struct would probably require 16
>>>>>>>> bytes rather than 4, of which one may be padding.
>>>>>>>
>>>>>>> Depending on the sizes and alignments of the various types, sure.
>>>>>>> So what?
>>>>>>>
>>>>>>
>>>>>>> If you have suggestions for alternate ways to define #embed, they might
>>>>>>> be interesting, but it's too late to change the existing specification.
>>>>>>>
>>>>>>
>>>>>> My early comments on this were about compiler performance. I suggested
>>>>>> there might be a way to turn 100,000 byte values in a file, directly
>>>>>> into a 100KB string or data block, without needing to first convert
>>>>>> 100,000 values into 100,000 integer expressions representated as tokens,
>>>>>> and to then parse those 100,000 expressions into AST nodes etc.
>>>>>>
>>>>>> DB suggested something like that was actually done. But you can't do
>>>>>> that if those 100,000 numbers represent from 100KB to 800KB of memory
>>>>>> depending on the data type of the strucure they're initialising.
>>>>>
>>>>> An implementation is free to simply pass a variant (or the directive
>>>>> itself) of #embed from the pre-processor to the compiler if the programmer
>>>>> isn't using -E, and the compiler could simply copy the embedded file
>>>>> into the object file directly, without processing it as a series of
>>>>> integer values. Much like the #file and #line directives passed by
>>>>> the pre-processor to the compiler.
>>>>
>>>> Sure, an implementation has to operate *as if* it implemented the 8
>>>> translation phases separately. But given a structure initialized with
>>>> #embed, it would have to generate additional code to initialize the
>>>> structure members from the bytes of the binary blob.
>>>
>>> Would it? Or could it simply assume that the binary blob
>>> is already in the same binary format that writing an instance
>>> of the structure from a C application on the same host would have created?
>>
>> That would depend on the sizes of the fields in the struct, and the size
>> of the integer constants in the #embed.
>
> I'm embedding a binary file. I want the representation in memory
> to be _exactly_ the same as in the file, regardless of how it is
> defined in the C code (array of char, array of int, array of long, struct whatever).
>

Then you would want a union of the struct type and an appropriately
sized unsigned char array, and initialise the unsigned char area with
the bytes of the file using #embed.


devel / comp.lang.c / Re: Implicit String-Literal Concatenation

Pages:12345
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor