Article View: comp.lang.c
Article #454Re: compare literals / if( "cat"== "dog") {}
From: Rosario19
Date: Fri, 16 Oct 2026 21:25
Date: Fri, 16 Oct 2026 21:25
32 lines
2569 bytes
2569 bytes
On Thu, 15 Oct 2026 12:09:06 +0200, Janis Papanagnou wrote:
>On 2026-10-15 11:36, Rosario19 wrote:
>> On Sat, 10 Oct 2026 23:02:54 +0200, fir
>>> have asked for that but i got somewhat holes im my memory and i
>>> dont exactly remember sometimes on which i wrote and on which not
>>>
>>> the problem is i need this adhos enums strongly and really, but those
>>> 'smth' are to shore i could use two of them f('some','thin') but it gets
>>> uglier and such code is like degraded
>>>
>>> in fact there could be quite easy solution - it is use string literals
>>> as such tags - i mean you dont need to use strcomp , you just need to
>>> have same string literals have same pointer then
>>>
>>> if("cat" == "cat") will return true and
>>> if("cat" == "dog") will return false
>>
>> I say if int is 4 chars this should return 1 in case of fist line
>> 0 in case the second line
>>
>> if((*(int*)"cat") == (*(int*)"cat")) return 1
>> if((*(int*)"cat") == (*(int*)"dog") ) return 0
>
>You are seriously suggesting that the semantics of "C" should
>depend on the actual string-length at runtime, that it should
>not have an unambiguous uniform semantics in the first place?
>
>Janis
no, but see x86 assembly result of above in my pc can do that as
aspected
Technical Details
Message-ID:
<1f55dlhqcktjqqrnu3rlj1rkmialteo368@4ax.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11ae962$2365v$1@dont-email.me> <6171dlho2h59l01e1jvp6so5cbddc5brct@4ax.com> <11aq8o2$206gh$2@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Rosario19 <Ros@invalid.invalid>
Newsgroups: comp.lang.c
Subject: Re: compare literals / if( "cat"== "dog") {}
Date: Fri, 16 Oct 2026 23:25:59 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <1f55dlhqcktjqqrnu3rlj1rkmialteo368@4ax.com>
References: <11ae962$2365v$1@dont-email.me> <6171dlho2h59l01e1jvp6so5cbddc5brct@4ax.com> <11aq8o2$206gh$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 16 Oct 2026 21:18:14 +0000 (UTC)
Injection-Info: dont-email.me;
logging-data="3851344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yv0EdZFCuGE1lZvwyNgdCcbQUOOb3RmQ="; posting-host="72a593c50c4281e4d88ff0b159edd52a"
Cancel-Lock: sha1:7SdaI6ctQYuyhgYJ4MZmjYT56zk= sha256:DbsUVOmMiXpSJCVkGrrP18pd2a5sAP4tqeTIAE/7pS4=
sha1:ldbySi2ccwu4HphWeM2lWmg1R2M= sha256:rVPuUyrsWl9edOfLYw9xXVtWuBkUCp7s6BrjNi2t+U0=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)