🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #147

Re: compare literals / if( "cat"== "dog") {}

#147
From: Johann 'Myrkraverk' Oskarsson
Date: Sat, 10 Oct 2026 21:53
22 lines
1932 bytes
On 10/11/2026 5:02 AM, fir wrote:
> if("cat" == "cat") will return true and
> if("cat" == "dog") will return false
> 
> 
> i probably asked that but if so once again
> 
> is there way to enforce it to work?

Sort of.  If you're /only/ comparing literals, you can apply the /GF
switch in MSVC, and then all the literals will compiled into a single
pool, and you can compare by the pointers.

Of course, the pointers still point to the pool, and that's important
to remember.

I'm sure GCC and clang have equivalent switches.
-- 
Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
Federated at https://fed.brid.gy/bsky/myrkraverk.bsky.social
Technical Details
Message-ID: <9tyyS.21373$VDn8.13923@fx14.ams4>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!news-out.netnews.com!s1-2.netnews.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!fx14.ams4.POSTED!not-for-mail
References: <11ae962$2365v$1@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!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!news-out.netnews.com!s1-2.netnews.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!fx14.ams4.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: compare literals / if( "cat"== "dog") {}
Newsgroups: comp.lang.c
References: <11ae962$2365v$1@dont-email.me>
Content-Language: en-US
From: Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Organization: Watcom Pro Ltd.
In-Reply-To: <11ae962$2365v$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <9tyyS.21373$VDn8.13923@fx14.ams4>
X-Complaints-To: abuse@easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 11 Oct 2026 05:53:08 +0800
X-Received-Bytes: 1632