Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken


devel / comp.lang.c / Re: Effect of CPP tags

SubjectAuthor
* Effect of CPP tagsJanis Papanagnou
+- Re: Effect of CPP tagsLowell Gilbert
+* Re: Effect of CPP tagsKaz Kylheku
|`* Re: Effect of CPP tagsSpiros Bousbouras
| `- Re: Effect of CPP tagsTim Rentsch
+* Re: Effect of CPP tagsJanis Papanagnou
|+* Re: Effect of CPP tagsLowell Gilbert
||+* Re: Effect of CPP tagsKeith Thompson
|||`* Re: Effect of CPP tagsKaz Kylheku
||| `* Re: Effect of CPP tagsKeith Thompson
|||  `* Re: Effect of CPP tagsTim Rentsch
|||   `* Re: Effect of CPP tagsKaz Kylheku
|||    +- Re: Effect of CPP tagsJames Kuyper
|||    +* Re: Effect of CPP tagsJames Kuyper
|||    |`* Re: Effect of CPP tagsKaz Kylheku
|||    | +* Re: Effect of CPP tagsJames Kuyper
|||    | |`- Re: Effect of CPP tagsTim Rentsch
|||    | `* Re: Effect of CPP tagsTim Rentsch
|||    |  `* Re: Effect of CPP tagsKeith Thompson
|||    |   +- Re: Effect of CPP tagsDavid Brown
|||    |   +* Re: Effect of CPP tagsTim Rentsch
|||    |   |`- Re: Effect of CPP tagsKeith Thompson
|||    |   `- Re: Effect of CPP tagsTim Rentsch
|||    `- Re: Effect of CPP tagsTim Rentsch
||+* Re: Effect of CPP tagsKaz Kylheku
|||+- Re: Effect of CPP tagsKaz Kylheku
|||`* Re: Effect of CPP tagsLowell Gilbert
||| `- Re: Effect of CPP tagsJanis Papanagnou
||`* Re: Effect of CPP tagsJanis Papanagnou
|| `- Re: Effect of CPP tagsKaz Kylheku
|+- Re: Effect of CPP tagsKaz Kylheku
|`* Re: Effect of CPP tagsScott Lurndal
| +* Re: Effect of CPP tagsJanis Papanagnou
| |`* Re: Effect of CPP tagsKeith Thompson
| | +* Re: Effect of CPP tagsScott Lurndal
| | |`* Re: Effect of CPP tagsDavid Brown
| | | `* Re: Effect of CPP tagsJames Kuyper
| | |  `- Re: Effect of CPP tagsDavid Brown
| | `- Re: Effect of CPP tagsTim Rentsch
| `- usleep (Was: Effect of CPP tags)Kenny McCormack
+* Re: Effect of CPP tagsLawrence D'Oliveiro
|`* Re: Effect of CPP tagsBart
| +* Re: Effect of CPP tagsDavid Brown
| |`* Re: Effect of CPP tagsKeith Thompson
| | `* Re: Effect of CPP tagsKaz Kylheku
| |  `* Re: Effect of CPP tagsBart
| |   +* Re: Effect of CPP tagsLawrence D'Oliveiro
| |   |`* Re: Effect of CPP tagsBart
| |   | `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |   |  `* Re: Effect of CPP tagsBart
| |   |   +* Re: Effect of CPP tagsScott Lurndal
| |   |   |+* Re: Effect of CPP tagsDavid Brown
| |   |   ||`- Re: Effect of CPP tagsBGB
| |   |   |`* Re: Effect of CPP tagsBart
| |   |   | `- Re: Effect of CPP tagsDavid Brown
| |   |   `- Re: Effect of CPP tagsLawrence D'Oliveiro
| |   `* Re: Effect of CPP tagsDavid Brown
| |    +* Re: Effect of CPP tagsBart
| |    |+- Re: Effect of CPP tagsScott Lurndal
| |    |+* Re: Effect of CPP tagsKaz Kylheku
| |    ||+* Re: Effect of CPP tagsBart
| |    |||`* Re: Effect of CPP tagsBart
| |    ||| +- Re: Effect of CPP tagsKeith Thompson
| |    ||| `* Re: Effect of CPP tagsKaz Kylheku
| |    |||  `* Re: Effect of CPP tagsKeith Thompson
| |    |||   +* Re: Effect of CPP tagsJanis Papanagnou
| |    |||   |`- Re: Effect of CPP tagsKeith Thompson
| |    |||   `- Re: Effect of CPP tagsKaz Kylheku
| |    ||`- Re: Effect of CPP tagsScott Lurndal
| |    |`- Re: Effect of CPP tagsDavid Brown
| |    `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     +* Re: Effect of CPP tagsChris M. Thomasson
| |     |`* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     | `* Re: Effect of CPP tagsChris M. Thomasson
| |     |  `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     |   +- Re: Effect of CPP tagsChris M. Thomasson
| |     |   +- Re: Effect of CPP tagsChris M. Thomasson
| |     |   +- Re: Effect of CPP tagsKaz Kylheku
| |     |   `- Re: Effect of CPP tagsBlue-Maned_Hawk
| |     +* Re: Effect of CPP tagsDavid Brown
| |     |+* Re: Effect of CPP tagsBart
| |     ||+* Re: Effect of CPP tagsDavid Brown
| |     |||+- Re: Effect of CPP tagsBlue-Maned_Hawk
| |     |||`* Re: Effect of CPP tagsBart
| |     ||| `* Re: Effect of CPP tagsDavid Brown
| |     |||  `* Re: Effect of CPP tagsBart
| |     |||   +* Re: Effect of CPP tagsChris M. Thomasson
| |     |||   |`- Re: Effect of CPP tagsChris M. Thomasson
| |     |||   +* Re: Effect of CPP tagstTh
| |     |||   |+- Re: Effect of CPP tagsLawrence D'Oliveiro
| |     |||   |+- Re: Effect of CPP tagsKaz Kylheku
| |     |||   |`* Re: Effect of CPP tagsBart
| |     |||   | `* Re: Effect of CPP tagsScott Lurndal
| |     |||   |  `* Re: Effect of CPP tagsBart
| |     |||   |   `* Re: Effect of CPP tagsDavid Brown
| |     |||   |    +* Re: Effect of CPP tagsKaz Kylheku
| |     |||   |    |`* Re: Effect of CPP tagsDavid Brown
| |     |||   |    | `- Re: Effect of CPP tagsKaz Kylheku
| |     |||   |    `* Re: Effect of CPP tagsBart
| |     |||   |     +* Re: Effect of CPP tagsScott Lurndal
| |     |||   |     |`* Re: Effect of CPP tagsBart
| |     |||   |     `* Re: Effect of CPP tagsDavid Brown
| |     |||   `* Re: Effect of CPP tagsDavid Brown
| |     ||`* Re: Effect of CPP tagsBlue-Maned_Hawk
| |     |`* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     `* Re: Effect of CPP tagsKaz Kylheku
| +- Re: Effect of CPP tagsRichard Damon
| +* Re: Effect of CPP tagsKaz Kylheku
| +* Re: Effect of CPP tagsBlue-Maned_Hawk
| `- Re: Effect of CPP tagsLawrence D'Oliveiro
`* Re: Effect of CPP tagsTim Rentsch

Pages:123456789101112131415161718192021222324252627
Re: Effect of CPP tags

<4yikN.127078$83n7.102850@fx18.iad>

  copy mid

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

  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!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: Effect of CPP tags
Newsgroups: comp.lang.c
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me> <ummhnp$rf7k$1@dont-email.me> <pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid> <umq4ra$1dt87$1@dont-email.me>
Lines: 38
Message-ID: <4yikN.127078$83n7.102850@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 31 Dec 2023 18:37:52 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 31 Dec 2023 18:37:52 GMT
X-Received-Bytes: 2275
 by: Scott Lurndal - Sun, 31 Dec 2023 18:37 UTC

BGB <cr88192@gmail.com> writes:
>On 12/30/2023 12:51 AM, Blue-Maned_Hawk wrote:
>> Bart wrote:
>>
>>> Why not have a dedicated header file that is the specific to a
>>> particular version of a C compiler for a given platform? That it can be
>>> streamlined for that purpose.
>>
>> In fact, this is similar to exactly what Plan 9 did: for include files
>> that had arch-dependent content, it'd have a separate version of them for
>> each arch, with an arch's versions of headers like these all stored in
>> their own directory.
>>
>
>Yeah, we don't actually need big monolithic C libraries, nor big
>monolithic C compilers, ...

What monolithic C libraries are you referring to? My application
links with a several dozen libraries, some at startup, some dynamically
at run-time. Nothing monolithic there. POSIX only requires that
-lc include the necessarily functionality for the POSIX API, it
doesn't require that the implementation use a single library/shared
object at run-time.

Both GCC and CLANG do just as you describe here:

>Though, it seems like a different kind of strategy could be possible:
>Split compilers into frontends and backends (which may exist as
>semi-independent projects).
>
>Frontend deals with source languages, compiles down to a common IR (with
>the IR taking the place of object files);
>Backend compiles this to the actual machine code, and does any linking,
>before emitting the actual binary.

See LLVM.

Re: Effect of CPP tags

<oAikN.127079$83n7.60577@fx18.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.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: Effect of CPP tags
Newsgroups: comp.lang.c
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me> <ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me> <87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com> <umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me> <ums2al$1p6jm$1@dont-email.me>
Lines: 26
Message-ID: <oAikN.127079$83n7.60577@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 31 Dec 2023 18:40:20 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 31 Dec 2023 18:40:20 GMT
X-Received-Bytes: 1651
 by: Scott Lurndal - Sun, 31 Dec 2023 18:40 UTC

Bart <bc@freeuk.cm> writes:
>On 31/12/2023 15:25, David Brown wrote:

>> I realise that you (and possibly others) might find it useful for a tool
>> to replace typedef identifiers with their definitions, but it could only
>> be done for some cases, and is not as simple as macro substitution.
>
>Take this program, which uses two nested typedefs and one macro:
>
> typedef short T;
> typedef T U;
> #define V U
>
> typedef struct R {
> V a, b, c;
> } S;
>
>Passed through 'gcc -E', it manages to expand the V in the struct with
>U. (-fdirectives-only doesn't even do that).
>
>So what are the types of 'a, b, c'? Across 1000s of line of code, they
>may need tracking down. At least, for someone not using your super-duper
>tools.

Perhaps you need to use better names than V, a, b, and c.

Re: Effect of CPP tags

<20231231104215.299@kylheku.com>

  copy mid

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

  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: Effect of CPP tags
Date: Sun, 31 Dec 2023 18:44:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20231231104215.299@kylheku.com>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<ums2al$1p6jm$1@dont-email.me>
Injection-Date: Sun, 31 Dec 2023 18:44:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc5f0f430fe1b4bd6cdf246437f21a94";
logging-data="1920372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ov7H12XrLs7OeEgGOrWITs8+MpQERoZE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:QiBbHITnbJvAYtBJF/oashzgmgA=
 by: Kaz Kylheku - Sun, 31 Dec 2023 18:44 UTC

On 2023-12-31, Bart <bc@freeuk.cm> wrote:
> Take this program, which uses two nested typedefs and one macro:
>
> typedef short T;
> typedef T U;
> #define V U
>
> typedef struct R {
> V a, b, c;
> } S;
>
> Passed through 'gcc -E', it manages to expand the V in the struct with
> U. (-fdirectives-only doesn't even do that).
>
> So what are the types of 'a, b, c'? Across 1000s of line of code, they
> may need tracking down. At least, for someone not using your super-duper
> tools.

Super duper tools like, oh, Exuberant Ctags from 2011, packaged in Ubuntu:

$ ctags --version
Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex

We run that and then super-duper editor Vim will use the tags
file to jump to the definition of V, and of U.

Re: Effect of CPP tags

<umsf3a$1qttt$1@dont-email.me>

  copy mid

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

  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: bc...@freeuk.cm (Bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 19:23:23 +0000
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <umsf3a$1qttt$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me> <umqv72$1kutd$1@dont-email.me>
<ums16d$1p232$1@dont-email.me> <20231231092345.849@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 31 Dec 2023 19:23:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="014d6908d1d6f507dfa083bd146a0149";
logging-data="1931197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19akcbNVNiQU+qwnog9Gv8XO6Plgx3Cibc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:uaU8UIX1QA1xeKDFBQ7GTu2tOUk=
In-Reply-To: <20231231092345.849@kylheku.com>
Content-Language: en-GB
 by: Bart - Sun, 31 Dec 2023 19:23 UTC

On 31/12/2023 17:26, Kaz Kylheku wrote:
> On 2023-12-31, Bart <bc@freeuk.cm> wrote:
>> and file handles. With DLL, a pointer malloc-ed in the host cannot be
>> freed within the DLL and vice versa.)
>
> What??? All DLLs are in the same address space. malloc and free are
> sister functions that typically live in the same DLL, and don't
> care what calls them.
>
> Maybe you're referring to one DLL's free not being able to handle
> pointers produced by another DLL's malloc.

I'm referring to the possibilty that, if host and DLL both import say
msvcrt.dll, that each may have its own instance of msvcrt.dll, with its
own static data. That would also be the case with two DLLs.

But I can't reproduce the kind of error that would cause.

So I was either mistaken, or it's been fixed in the last decade, or
maybe my original test failed for other reasons, eg. because of
statically linked libraries not shared ones, or mixed compilers (and do
libraries) were used.

Re: Effect of CPP tags

<umsfum$1qttt$2@dont-email.me>

  copy mid

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

  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: bc...@freeuk.cm (Bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 19:37:59 +0000
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <umsfum$1qttt$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<ums2al$1p6jm$1@dont-email.me> <20231231104215.299@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 31 Dec 2023 19:37:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="014d6908d1d6f507dfa083bd146a0149";
logging-data="1931197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Jvcs+gtX+/uGNt1newQ3zCRhBDEfaCXU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cTb/xXD5PcDSPDbHH2cKuw9gL7A=
Content-Language: en-GB
In-Reply-To: <20231231104215.299@kylheku.com>
 by: Bart - Sun, 31 Dec 2023 19:37 UTC

On 31/12/2023 18:44, Kaz Kylheku wrote:
> On 2023-12-31, Bart <bc@freeuk.cm> wrote:
>> Take this program, which uses two nested typedefs and one macro:
>>
>> typedef short T;
>> typedef T U;
>> #define V U
>>
>> typedef struct R {
>> V a, b, c;
>> } S;
>>
>> Passed through 'gcc -E', it manages to expand the V in the struct with
>> U. (-fdirectives-only doesn't even do that).
>>
>> So what are the types of 'a, b, c'? Across 1000s of line of code, they
>> may need tracking down. At least, for someone not using your super-duper
>> tools.
>
> Super duper tools like, oh, Exuberant Ctags from 2011, packaged in Ubuntu:
>
> $ ctags --version
> Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
> Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
> Optional compiled features: +wildcards, +regex
>
> We run that and then super-duper editor Vim will use the tags
> file to jump to the definition of V, and of U.

Actually ctags appears to be also part of Windows.

I've played with it and the results are interesting.

I've recently created something vaguely similar for my language, invoked
via the compiler (mm -getst prog) which scans all modules and produces a
list of references (currently only top-level names) to help find them
from my IDE.

I don't know how useful ctags might be in helping extract bindings from
a complex set of API headers, but I've got that covered.

Re: Effect of CPP tags

<umsgf8$1r2mh$1@dont-email.me>

  copy mid

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

  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: news.x.r...@xoxy.net (Richard Damon)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 14:46:47 -0500
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <umsgf8$1r2mh$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me> <umqv72$1kutd$1@dont-email.me>
<ums16d$1p232$1@dont-email.me> <20231231092345.849@kylheku.com>
<umsf3a$1qttt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 31 Dec 2023 19:46:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="77d9789a18b3a855cdcc834289666fd9";
logging-data="1936081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19i2jGKHo2wOfh5a7GhJMsozRZEZseBx3Q="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:5BQxaAdcOscsaW94J0P0dvnqo5k=
Content-Language: en-US
In-Reply-To: <umsf3a$1qttt$1@dont-email.me>
 by: Richard Damon - Sun, 31 Dec 2023 19:46 UTC

On 12/31/23 2:23 PM, Bart wrote:
> On 31/12/2023 17:26, Kaz Kylheku wrote:
>> On 2023-12-31, Bart <bc@freeuk.cm> wrote:
>>> and file handles. With DLL, a pointer malloc-ed in the host cannot be
>>> freed within the DLL and vice versa.)
>>
>> What??? All DLLs are in the same address space. malloc and free are
>> sister functions that typically live in the same DLL, and don't
>> care what calls them.
>>
>> Maybe you're referring to one DLL's free not being able to handle
>> pointers produced by another DLL's malloc.
>
> I'm referring to the possibilty that, if host and DLL both import say
> msvcrt.dll, that each may have its own instance of msvcrt.dll, with its
> own static data. That would also be the case with two DLLs.
>
> But I can't reproduce the kind of error that would cause.
>
> So I was either mistaken, or it's been fixed in the last decade, or
> maybe my original test failed for other reasons, eg. because of
> statically linked libraries not shared ones, or mixed compilers (and do
> libraries) were used.
>
>

Sounds like either something used a static library or forced the system
to link in two different copies of msvcrt.dll (perhaps by incorrectly
including their own in an off-path directory)

This wasn't that uncommon of a problem until people got burned enough by
not following "the rules" that they started to do it right.

Re: Effect of CPP tags

<xLjkN.37422$TSTa.28283@fx47.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.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: Effect of CPP tags
Newsgroups: comp.lang.c
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me> <ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me> <87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com> <umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me> <ums2al$1p6jm$1@dont-email.me> <20231231104215.299@kylheku.com>
Lines: 39
Message-ID: <xLjkN.37422$TSTa.28283@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sun, 31 Dec 2023 20:00:29 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sun, 31 Dec 2023 20:00:29 GMT
X-Received-Bytes: 2127
 by: Scott Lurndal - Sun, 31 Dec 2023 20:00 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
>On 2023-12-31, Bart <bc@freeuk.cm> wrote:
>> Take this program, which uses two nested typedefs and one macro:
>>
>> typedef short T;
>> typedef T U;
>> #define V U
>>
>> typedef struct R {
>> V a, b, c;
>> } S;
>>
>> Passed through 'gcc -E', it manages to expand the V in the struct with
>> U. (-fdirectives-only doesn't even do that).
>>
>> So what are the types of 'a, b, c'? Across 1000s of line of code, they
>> may need tracking down. At least, for someone not using your super-duper
>> tools.
>
>Super duper tools like, oh, Exuberant Ctags from 2011, packaged in Ubuntu:
>
>$ ctags --version
>Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
> Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
> Optional compiled features: +wildcards, +regex
>
>We run that and then super-duper editor Vim will use the tags
>file to jump to the definition of V, and of U.

Or the super-duper tool called cscope.

$ find . -name '*.[chCHsS]*' -print |grep -v .svn |sort -u | cscope -q -b -k -f csc -i -

Which the super-duper VIM editor will leverage for both
tags support and cscope query support.

$ vim
:cs add csc
:cs f 1 main

Re: Effect of CPP tags

<umsn6k$1ro5b$6@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 21:41:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <umsn6k$1ro5b$6@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <umnrnh$115ko$1@dont-email.me>
<umntgt$11bra$1@dont-email.me> <umqgia$1f5qb$2@dont-email.me>
<umqibc$1fc63$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 31 Dec 2023 21:41:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bd4079529680d5d55fee8a00114cbf27";
logging-data="1958059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NdHSvUg/0sDBCN+TNr65W"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:t/9WJg6bR7j8xD63AhPHoQcewqw=
 by: Lawrence D'Oliv - Sun, 31 Dec 2023 21:41 UTC

On Sun, 31 Dec 2023 02:06:37 +0000, Bart wrote:

> I have plenty of ideas, but people are generally not interested.

Lessig’s Law: “the one who writes the code, makes the rules”.

Nobody cares about “ideas”. “Ideas” are a dime a dozen. What matters is
execution. Put your “idea” into working code, and that will prove your
point.

Re: Effect of CPP tags

<umsnbn$1ro5b$7@dont-email.me>

  copy mid

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

  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: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 21:44:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <umsnbn$1ro5b$7@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 31 Dec 2023 21:44:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bd4079529680d5d55fee8a00114cbf27";
logging-data="1958059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GdaF7OwRShjY4mbZ+de9j"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:0nf8yBwt3rfQGnBms/+KZ23qlcU=
 by: Lawrence D'Oliv - Sun, 31 Dec 2023 21:44 UTC

On Sun, 31 Dec 2023 16:25:08 +0100, David Brown wrote:

> I realise that you (and possibly others) might find it useful for a tool
> to replace typedef identifiers with their definitions, but it could only
> be done for some cases, and is not as simple as macro substitution.

String-based macros are nothing but trouble. Typedefs are scoped, string
macros are not.

If you want to see the right way to do macros, look at LISP, where they
are token-based, and much more robust as as result. I think they even
manage to apply scoping rules to macro definitions as well.

Re: Effect of CPP tags

<umsnkk$1rvfm$1@dont-email.me>

  copy mid

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

  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: cr88...@gmail.com (BGB)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 15:49:05 -0600
Organization: A noiseless patient Spider
Lines: 580
Message-ID: <umsnkk$1rvfm$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me> <umqv72$1kutd$1@dont-email.me>
<ums16d$1p232$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 31 Dec 2023 21:49:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3d435c33f4a089fd22823e1e74aca625";
logging-data="1965558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ShwFEKfn8erfyOu3Kz+/b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ta55UWdNUNlr4CCiz9yR2hZSsmw=
In-Reply-To: <ums16d$1p232$1@dont-email.me>
Content-Language: en-US
 by: BGB - Sun, 31 Dec 2023 21:49 UTC

On 12/31/2023 9:26 AM, Bart wrote:
> On 31/12/2023 05:46, BGB wrote:
>> On 12/30/2023 8:18 PM, Bart wrote:
>>> On 31/12/2023 01:34, Lawrence D'Oliveiro wrote:
>>>> On Sat, 30 Dec 2023 19:14:55 -0600, BGB wrote:
>>>>
>>>>> Note that (unlike ELF on Linux), it is not currently possible to
>>>>> directly share global variables across DLL boundaries.
>>>>
>>>> Windows is broken in so many ways ... when you achieve something, it’s
>>>> like getting a bear to dance: it’s not that it dances badly, but
>>>> that it
>>>> dances at all.
>>> I think that that limitation was specific to BGB's handling of DLLs;
>>> it was not made clear.
>>>
>>
>> Yes.
>>
>> In my case (for my custom target) I am using a modified version of
>> PE/COFF (with some tweaks, *), but it has the issue that there is not
>> currently (any) mechanism for sharing variables across DLL boundaries
>> apart from getter/setter functions or similar.
>
> I find PE/COFF format a nightmare. I did eventually get my tools to
> generate first OBJ then EXE files. But when it came to DLL, there was
> something wrong in the files I generated that I couldn't fix.
>
> So for a couple of years, I created my own shared library format,
> utterly different from PE+, and about 10 times simpler.
>
> The shared library files were called ML, and I extended it to standalone
> executables called MX files.
>
> However ML libraries could only be used from my languages, and MX files
> needed a small conventional EXE loader to get started.
>
> Eventually I fixed the problems with DLL. (Partly it was that my
> generated code wasn't fully position-independent and only ran in
> low-memory below 2GB, but there was also a bug in the base-reloc tables.)
>
> Now, sadly, I will probably drop my ML/MX files, even though my MLs have
> advantages over DLLs. (Eg. they have the same environment as the host
> apps, so that they can share things like pointers to allocated memory
> and file handles. With DLL, a pointer malloc-ed in the host cannot be
> freed within the DLL and vice versa.)
>

OK.

I had considered a fully custom format at one point, original idea would
have been something vaguely resembling a AR or TAR file, say:
Program Header;
Segment Header;
LZ compressed segment;
Segment Header;
LZ compressed segment;
...

Where say, each segment may have one or more sections, specify a loader
address, and may include additional commands for what to do with it
(such as interpreting it as base relocs rather than being part of the
final image).

Technically, this would have also been along vaguely similar lines to
the Mach-O format.

But ended up opting with a modified PE/COFF as it already had most of
what I wanted (and I was already reasonably familiar with the format).
My case differed slightly in that I didn't need to care about whether
Windows or existing tools could understand the binaries, and so "PEL4"
is sort of its own format in a way as well.

Technically, it still fit what I wanted to do better than what ELF would
have been, though I had ended up tweaking some stuff to allow it to
support loading multiple binaries into the same address space:
All binaries include reloc tables;
The read-only and read/write sections are split up into two different
segments (using the Global Pointer data-directory entry to effectively
define the read/write section, with the Global Pointer pointed to the
start of this segment on program start-up).

I had looked into a few possible compression schemes, and LZ4 gave the
best properties for binaries.

I have a different (byte-oriented) compression scheme that tends to give
better compression for general purpose data compression, but LZ4 seemed
to give better results with executable code in this case.

>
>>> Each DLL exports certain symbols such as the addresses of functions
>>> and variables. So no reason you can't access a variable exported from
>>> any DLL, unless perhaps multiple instances of the same DLL have to
>>> share the same static data, but that sounds very unlikely, as little
>>> would work.
>>>
>>
>> Much past roughly Win9x or so, it has been possible to use
>> "__declspec(dllimport)" on global variables in Windows (in an earlier
>> era, it was not possible to use the __declspec's, but instead
>> necessary to manage DLL import/exports by writing out lists in ".DEF"
>> files).
>>
>> It isn't entirely transparent, but yes, on actual Windows, it is very
>> much possible to share global variables across DLL boundaries.
>>
>>
>> Just, this feature is not (yet) supported by my compiler. Personally,
>> I don't see this as a huge loss (even if it did work; I personally see
>> it as "poor coding practice").
>
> This is a language issue. Or, in C, it is compiler related.
>
> I've never been quite sure how you tell a C compiler to export a certain
> symbol when creating a DLL. Sometimes it just works; I think it just
> exports everything that is not static (it may depend on a compiler
> option too).
>
> And some compilers may need this __declspec business, but I've never
> bothered with it.
>

Yeah. GCC seems to be "export everything".

MSVC needs either __declspec or ".DEF" files.

I am not sure when exactly __declspec started being used for this,
seemingly sometime between "Visual C++ 4.0" and "Visual Studio 2003".
This isn't really documented online to really narrow it down much further.

In my case, I went with using a similar approach to MSVC, namely
explicit export.

Where the normal "extern" storage class is shared between translation
units, but does not cross DLL boundaries.

> Mine just exports all not-static names. So this program:
>
>    int abc;
>    static int def;
>
>    void F(void) {}
>    static void G(void) {}
>
> if compiled as: 'mcc -dll prog', produces a file prog.dll which, if I
> dump it, shows this export table:
>
>  Export Directory
>
>     0 00000000        0 Fun F
>     1 00000000        0 Var abc
>
> (There's something in it that distinguishes functions from variables,
> but I can't remember the details.)
>
> In any case, in C it can be hit and miss. In my own language, it is more
> controlled: I used an 'export' prefix to export symbols from a program.
>
> (It also conventiently creates interface files to be able to use the DLL
> library from a program. The equivalent of prog.h for my example
> containing the API needed to use it. Rolling that out to C is not
> practical however as my 'export' applies also to things like types and
> enums.)
>

In my case, there are two major ways of invoking the compiler, say:
bgbcc /Fefoo.dll foo.c
Or:
bgbcc -o foo.dll foo.c

Where the compiler uses the file extension, and if it is DLL, it assumes
you want a DLL:
EXE: EXE file, "PBO ABI", fully relocatable.
DLL: DLL file, "PBO ABI", fully relocatable.
SYS: Bare-metal EXE, ABI more like traditional Win32 EXEs.
BIN: ROM image, no EXE headers, no relocs, ...
RIL: RIL Bytecode
OBJ: RIL Bytecode
O: Also RIL Bytecode
S: ASM output.

If no output file is given, it looks at whether it is trying to mimic
GCC style command-line behavior:
No: Assume "foo.exe" as default output.
Yes: Assume "a.exe" as default output.

Where, say, for the GCC-like mode:
-o <name> Output file.
-c Compile only
-E Preprocess only
-S ASM only.
-I<path> Add include path
-L<path> Add library path
-S<path> Add source path (excludes '-S' by itself)
-l<name> Add library
-D<name>[=<value>] #define something
-W<opt> Warning option
-m<tgt> Specify target machine
-f<opt> Specify target option/flag
-O<opt> Specify optimizer option.
-Z<opt> Specify debug option.
-g<opt> Also specify debug option.
...

For libraries, it checks the library path, where for "-l<name>" it will
look for:
lib<name>.<arch>.ril
lib<name>.ril
Assuming static linking in this case (the handling for DLLs is a little
different).

Note that, sort of like with MSVC, any debug data is dumped into
external files, and is not held within the EXE itself. Thus far, it is
fairly limited, mostly as a big ASCII text file with with a vaguely
similar structure to "nm" output.


Click here to read the complete article
Re: Effect of CPP tags

<umsnp0$1rsv3$1@dont-email.me>

  copy mid

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

  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: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 13:51:28 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <umsnp0$1rsv3$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<umsnbn$1ro5b$7@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 31 Dec 2023 21:51:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b3a45f802fb88652a535eaac0edd3bc6";
logging-data="1962979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/X+bM4uTf937cC+vu8qBZdsXYozEIh9W8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HoTZg7LHEmvDW/BWD9cqbnQ6S/U=
In-Reply-To: <umsnbn$1ro5b$7@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 31 Dec 2023 21:51 UTC

On 12/31/2023 1:44 PM, Lawrence D'Oliveiro wrote:
> On Sun, 31 Dec 2023 16:25:08 +0100, David Brown wrote:
>
>> I realise that you (and possibly others) might find it useful for a tool
>> to replace typedef identifiers with their definitions, but it could only
>> be done for some cases, and is not as simple as macro substitution.
>
> String-based macros are nothing but trouble. Typedefs are scoped, string
> macros are not.
>
> If you want to see the right way to do macros, look at LISP, where they
> are token-based, and much more robust as as result. I think they even
> manage to apply scoping rules to macro definitions as well.

Fwiw, check this out:

https://github.com/rofl0r/chaos-pp

:^)

Re: Effect of CPP tags

<umsoag$1s2bb$1@dont-email.me>

  copy mid

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

  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: bc...@freeuk.cm (Bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 22:00:49 +0000
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <umsoag$1s2bb$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<ums2al$1p6jm$1@dont-email.me> <20231231104215.299@kylheku.com>
<umsfum$1qttt$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 31 Dec 2023 22:00:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="014d6908d1d6f507dfa083bd146a0149";
logging-data="1968491"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C1LSKDbVo8DrnEjeOu0Gt/4bNgqC/IAA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:wQGs5QZkgJNq4F+xgpIxDoemG3U=
Content-Language: en-GB
In-Reply-To: <umsfum$1qttt$2@dont-email.me>
 by: Bart - Sun, 31 Dec 2023 22:00 UTC

On 31/12/2023 19:37, Bart wrote:
> On 31/12/2023 18:44, Kaz Kylheku wrote:
>> On 2023-12-31, Bart <bc@freeuk.cm> wrote:
>>> Take this program, which uses two nested typedefs and one macro:
>>>
>>>      typedef short T;
>>>      typedef T U;
>>>      #define V U
>>>
>>>      typedef struct R {
>>>          V a, b, c;
>>>      } S;
>>>
>>> Passed through 'gcc -E', it manages to expand the V in the struct with
>>> U. (-fdirectives-only doesn't even do that).
>>>
>>> So what are the types of 'a, b, c'? Across 1000s of line of code, they
>>> may need tracking down. At least, for someone not using your super-duper
>>> tools.
>>
>> Super duper tools like, oh, Exuberant Ctags from 2011, packaged in
>> Ubuntu:
>>
>> $ ctags --version
>> Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
>>    Addresses: <dhiebert@users.sourceforge.net>,
>> http://ctags.sourceforge.net
>>    Optional compiled features: +wildcards, +regex
>>
>> We run that and then super-duper editor Vim will use the tags
>> file to jump to the definition of V, and of U.
>
> Actually ctags appears to be also part of Windows.

That's not the case, it just happened to be bundled with Windows.

It's a 1.25MB file so fairly 'super', compared with my stuff. The option
I said I'd added to my compiler was about 70 lines of extra code, but it
looks to be a bit more sophisticated as the compiler has done the hard
work, and it just dumps parts of the symbol table.

>> We run that and then super-duper editor Vim will use the tags
>> file to jump to the definition of V, and of U.

How does Vim know where in the file to look? The TAGS files I've managed
to produce doesn't have that info, and I can't see anything in the help
to add it.

How do you get it to look inside header files, or do those have to be
submitted manually?

Re: Effect of CPP tags

<86frzit2hx.fsf@linuxsc.com>

  copy mid

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

  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: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 14:45:46 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <86frzit2hx.fsf@linuxsc.com>
References: <umet9d$3hir9$1@dont-email.me> <20231226143131.916@kylheku.com> <ib2w1CqX8rwIzAb9V@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="5ace88928e20b7842ad42526ffee8c84";
logging-data="1978593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+b6eHpnGh8FOHsxl/1ipQegevtI+l1uu0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:1VDehztTvpS7sJt+IHDvGKc42To=
sha1:Mr8x5JHkiYmEMxuxirpGUDw09uw=
 by: Tim Rentsch - Sun, 31 Dec 2023 22:45 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

[... on #define _BSD_SOURCE, etc ...]

> By the way , this kind of question is more appropriate for
> comp.unix.programmer .

For what it's worth, I found the discussion valuable. I
look at comp.unix.programmer only sporadically, so I'm
glad it was posted here.

Re: Effect of CPP tags

<umsrp3$1sfth$1@dont-email.me>

  copy mid

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

  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: cr88...@gmail.com (BGB)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 16:59:44 -0600
Organization: A noiseless patient Spider
Lines: 106
Message-ID: <umsrp3$1sfth$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <4yikN.127078$83n7.102850@fx18.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 31 Dec 2023 22:59:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3d435c33f4a089fd22823e1e74aca625";
logging-data="1982385"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sOet5PfvWHWn/Ku24GykL"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fgs0nLLfUehNY5s2cX+i9GQwq14=
Content-Language: en-US
In-Reply-To: <4yikN.127078$83n7.102850@fx18.iad>
 by: BGB - Sun, 31 Dec 2023 22:59 UTC

On 12/31/2023 12:37 PM, Scott Lurndal wrote:
> BGB <cr88192@gmail.com> writes:
>> On 12/30/2023 12:51 AM, Blue-Maned_Hawk wrote:
>>> Bart wrote:
>>>
>>>> Why not have a dedicated header file that is the specific to a
>>>> particular version of a C compiler for a given platform? That it can be
>>>> streamlined for that purpose.
>>>
>>> In fact, this is similar to exactly what Plan 9 did: for include files
>>> that had arch-dependent content, it'd have a separate version of them for
>>> each arch, with an arch's versions of headers like these all stored in
>>> their own directory.
>>>
>>
>> Yeah, we don't actually need big monolithic C libraries, nor big
>> monolithic C compilers, ...
>
> What monolithic C libraries are you referring to? My application
> links with a several dozen libraries, some at startup, some dynamically
> at run-time. Nothing monolithic there. POSIX only requires that
> -lc include the necessarily functionality for the POSIX API, it
> doesn't require that the implementation use a single library/shared
> object at run-time.
>

Not in terms of "one C library has all the code" but rather, "everything
is expected to use the same C library" (such as GLIBC on Linux).

Granted, there are (sort of) Newlib and Musl as alternative libc's.

>
> Both GCC and CLANG do just as you describe here:
>
>> Though, it seems like a different kind of strategy could be possible:
>> Split compilers into frontends and backends (which may exist as
>> semi-independent projects).
>>
>> Frontend deals with source languages, compiles down to a common IR (with
>> the IR taking the place of object files);
>> Backend compiles this to the actual machine code, and does any linking,
>> before emitting the actual binary.
>
> See LLVM.
>

LLVM bitcode would be kind of a pain though to deal with in anything
that is not LLVM (exposes too many aspects of LLVM in its design, and
not really documented in a way that makes sense outside the context of
LLVM).

My own preference here would be for something more like .NET CIL, but
adapted to make more sense for a language like C (granted, compiling C
to .NET CIL is still less bad than some of the other options, such as
JVM/Flash/WASM/... which generally involved needing to go through a lot
of awkward contortions).

Main drawback of LLVM is mostly that it is a pain to recompile from
source, and writing a new backend for LLVM would presumably require
rebuilding it frequently, which is not an attractive option if it takes
30 minutes or so for each rebuild.

As for GCC, it seems not so much to split the compiler into a frontend
and backend; so much as to split and scatter each target across all of
binutils (so, would need to poke at LD, GAS, BFD, ... at each step
adding awareness of the specific aspects of the target relevant to the
component in question).

So, adding a target like mine would likely require touching pretty much
every part of the toolchain, which is already well into MLOC territory.

Well, and in this case, GCC is more like a confederation of tools and
libraries.

Rather than there being any obvious "backend module":
Well, say, if one imagines the compiler backend as sort of like a video
codec module, where one gives it inputs and configures the desired
operation and output using FOURCC's and similar ("Here is the 3AC and
metadata for a program; give me the output as a DLL"...).

GCC just doesn't work this way:
Like, it more goes as layers:
C -> preprocessor output;
PP-out -> AST -> GIMPLE;
GIMPLE -> ASM;
ASM -> OBJ;
Pass OBJ's to LD;
...
With, generally, each part of the process existing as multiple binaries
and using temporary files to move data around.

Granted, when I started my project, I didn't expect that my compiler
would end up being 250 kLOC, and there are a few things I did that were
obvious design missteps in retrospect.

In particular, I would prefer cleaner separation between internal
subsystems and stages. I had intended to address some issues in an
attempt at a new ground-up compiler design, but this effort stalled.

....

Re: Effect of CPP tags

<umsufv$1snq9$2@dont-email.me>

  copy mid

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

  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: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 23:46:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <umsufv$1snq9$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 31 Dec 2023 23:46:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="942470baad9a35e821becc4bfe3b8b3b";
logging-data="1990473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191uoJkKfJcrHj4DHcCstLu"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:EbMaWV1V7ito2UV3QQiziB7UQSw=
 by: Lawrence D'Oliv - Sun, 31 Dec 2023 23:46 UTC

On Sun, 31 Dec 2023 02:18:25 +0000, Bart wrote:

> This somes my experience of software originating in Linux. This is why
> Windows had to acquire CYGWIN then MSYS then WSL. You can't build the
> simplest program without involving half of Linux.

On Linux, we have package managers that only pull in the needed
dependencies. Windows just seems actively hostile to that kind of
infrastructure management. If you meant “you can’t build the simplest
program *on Windows* without involving half of Linux” ... well, that’s
just a reflection on the deficiencies of Windows. On Linux, you already
have the *whole* of Linux to start with.

Re: Effect of CPP tags

<878r59vs1c.fsf@nosuchdomain.example.com>

  copy mid

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

  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: Effect of CPP tags
Date: Sun, 31 Dec 2023 16:03:27 -0800
Organization: None to speak of
Lines: 39
Message-ID: <878r59vs1c.fsf@nosuchdomain.example.com>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com>
<20231229122012.850@kylheku.com> <umnhtf$103sg$1@dont-email.me>
<ums14k$1p0rs$1@dont-email.me> <ums2al$1p6jm$1@dont-email.me>
<20231231104215.299@kylheku.com> <umsfum$1qttt$2@dont-email.me>
<umsoag$1s2bb$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5cfe2e3f2648fa7c3f92bc4f108bd948";
logging-data="1996576"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sJsLeXDYTJ2uoGH+VTPeD"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:7NCpxgcEJehj6Tby8op8XaGWZjo=
sha1:7SnVsXmAO1tfd3YrZJWC88gDSsg=
 by: Keith Thompson - Mon, 1 Jan 2024 00:03 UTC

Bart <bc@freeuk.cm> writes:
> On 31/12/2023 19:37, Bart wrote:
[...]
>> Actually ctags appears to be also part of Windows.
>
> That's not the case, it just happened to be bundled with Windows.

I'd be very surprised if ctags were "bundled with Windows".

On my Windows system, I have a ctags command that's part of OpenWatcom,
which I apparently installed several years ago.

The most common version on Linux-like systems is "exuberant-ctags".
The OpenWatcom version appears to be a different implementation.

There are also versions available via Cygwin and WSL. Perhaps you
wouldn't be interested in those.

I don't know what version you have.

[...]

> How does Vim know where in the file to look? The TAGS files I've
> managed to produce doesn't have that info, and I can't see anything in
> the help to add it.
>
> How do you get it to look inside header files, or do those have to be
> submitted manually?

For the "exuberant" version, you invoke it with the names of the
files you want to index, and the "tags" file includes line numbers.
The OpenWatcom version appears to generate search patterns rather
than line numbers, which makes the tags file more stable as files
are edited. I don't know what version you have.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Effect of CPP tags

<86bka5uda0.fsf@linuxsc.com>

  copy mid

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

  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: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 16:07:35 -0800
Organization: A noiseless patient Spider
Lines: 104
Message-ID: <86bka5uda0.fsf@linuxsc.com>
References: <umet9d$3hir9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="4ad5b29cc5222e274263b40ba81c3fd0";
logging-data="1997534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZrdX0/fFg0PhjGZgIrYfNyY37lbG0fjk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:AruI019hRVodaTSu3/owi48jz5A=
sha1:bxR+WLdHorRGD5OCKE+BYUnoyTs=
 by: Tim Rentsch - Mon, 1 Jan 2024 00:07 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

> This is a CPP question that arose last month. It's not about an
> actual issue with the software, just out of curiosity and to be sure
> it works reliable (it seemingly does).
>
> In a C99 program on Linux (Ubuntu) I intended to use usleep() and
> then also strnlen().
>
> When I added usleep() and its include file I got an error and was
> asked to define the CPP tag '_BSD_SOURCE'. I did so, and because I
> wanted side effects of that tag kept as small as possible I
> prepended it just before the respective #include and put it at the
> end of my #include list
>
> ...other #includes...
> #define _BSD_SOURCE
> #include <unistd.h>
>
> But as got obvious *that* way there had been side-effects and I
> had to put the tag at the beginning of all include files (which
> astonished me)
>
> #define _BSD_SOURCE
> #include <unistd.h>
> ...other #includes here...
>
> For the strnlen() function I needed another CPP tag, '_GNU_SOURCE'.
> So now I have both CPP tag definitions before the includes

I second the recommendations of Lowell Gilbert and others not to
define _BSD_SOURCE or _GNU_SOURCE (especially not _GNU_SOURCE)
but instead seek alternatives, which are readily available for
the two functionalities being sought in this case.

> #define _GNU_SOURCE /* necessary for strnlen() in string.h */
> #define _BSD_SOURCE /* necessary for usleep() in unistd.h */
> ...all #includes here...

For strnlen(), put an inline definition in a header file:

#ifndef HAVE_strnlen_dot_h_header
#define HAVE_strnlen_dot_h_header

#include <stddef.h>

static inline size_t
strnlen( const char *s, size_t n ){
extern void *memchr( const void *, int, size_t );
const char *p = memchr( s, 0, n );
return p ? (size_t){ p-s } : n;
}

#include <string.h>

#endif

Disclaimer: this code has been compiled but not tested.

(If you want you could call this header file "string.h" and do
a #include "string.h". I'm not advocating doing that, just
pointing it out as an alternative. I expect some people like the
idea, and others dislike it, and I don't want to get involved in
a style war.)

For usleep(), define an alternate function usnooze(), to be used
in place of usleep(). In header file usnooze.h:

extern int usnooze( unsigned long long );

In source file usnooze.c:

#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif

#include "usnooze.h"

#include <errno.h>
#include <time.h>

int
usnooze( unsigned long long snooze_time_in_microseconds ){
typedef unsigned long long ULL;
typedef struct timespec TS;

ULL seconds = snooze_time_in_microseconds / 1000000;
ULL nanoseconds = snooze_time_in_microseconds % 1000000 * 1000;
TS need = { .tv_sec = seconds, .tv_nsec = nanoseconds };
TS more;
int rc;
unsigned most = 1000;

while( errno = 0, rc = nanosleep( & need, & more ), rc != 0 ){
if( errno != EINTR || most-- == 0 ) return -1;
need = more;
}

return 0;
}

The point of putting the definition of usnooze() in a separate file
is so the needed #define _POSIX_C_SOURCE doesn't contaminate any
more program source than it has to.

Re: Effect of CPP tags

<umt00t$1subn$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 1 Jan 2024 00:12:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <umt00t$1subn$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<umsnbn$1ro5b$7@dont-email.me> <umsnp0$1rsv3$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 1 Jan 2024 00:12:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="942470baad9a35e821becc4bfe3b8b3b";
logging-data="1997175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/k1Ysfd1xzYhS9ujI2vF+r"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:E/fR+BhpIKBPKDPoCQmp+O6s0eM=
 by: Lawrence D'Oliv - Mon, 1 Jan 2024 00:12 UTC

On Sun, 31 Dec 2023 13:51:28 -0800, Chris M. Thomasson wrote:

> On 12/31/2023 1:44 PM, Lawrence D'Oliveiro wrote:
>>
>> If you want to see the right way to do macros, look at LISP, where they
>> are token-based, and much more robust as as result. I think they even
>> manage to apply scoping rules to macro definitions as well.
>
> Fwiw, check this out:
>
> [dead project with spam link omitted]

Looks long defunct, which is just as well.

I really did give string-based macros a try. I thought it was just down to
deficiencies in the C/C++ preprocessor. So I did some work with GNU M4,
which is about as powerful a string macro processor as you could want. And
instead of being better, it was just as troublesome and fragile.

The watchword now is “homoiconicity”. This means that the program has an
AST representation in terms of objects in the language itself. LISP has
this very naturally. And all your macro-type manipulations are done on
this intermediate representation, not on the original program source.

I found a way to do it Python, too, which I used for this project
<https://gitlab.com/ldo/seaskirt> to generate both synchronous and
asynchronous versions of the same API classes from common code.

Re: Effect of CPP tags

<874jfxvqi0.fsf@nosuchdomain.example.com>

  copy mid

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

  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: Effect of CPP tags
Date: Sun, 31 Dec 2023 16:36:39 -0800
Organization: None to speak of
Lines: 83
Message-ID: <874jfxvqi0.fsf@nosuchdomain.example.com>
References: <umet9d$3hir9$1@dont-email.me> <86bka5uda0.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5cfe2e3f2648fa7c3f92bc4f108bd948";
logging-data="2003726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fZZ+oR5LPFM++TmqN67+Y"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:iFkwepPj8PjB0jIp2HRq1LnigQk=
sha1:8H12Y70M99pkF3gwNmM9hn/CU0I=
 by: Keith Thompson - Mon, 1 Jan 2024 00:36 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> This is a CPP question that arose last month. It's not about an
>> actual issue with the software, just out of curiosity and to be sure
>> it works reliable (it seemingly does).
>>
>> In a C99 program on Linux (Ubuntu) I intended to use usleep() and
>> then also strnlen().
>>
>> When I added usleep() and its include file I got an error and was
>> asked to define the CPP tag '_BSD_SOURCE'. I did so, and because I
>> wanted side effects of that tag kept as small as possible I
>> prepended it just before the respective #include and put it at the
>> end of my #include list
>>
>> ...other #includes...
>> #define _BSD_SOURCE
>> #include <unistd.h>
>>
>> But as got obvious *that* way there had been side-effects and I
>> had to put the tag at the beginning of all include files (which
>> astonished me)
>>
>> #define _BSD_SOURCE
>> #include <unistd.h>
>> ...other #includes here...
>>
>> For the strnlen() function I needed another CPP tag, '_GNU_SOURCE'.
>> So now I have both CPP tag definitions before the includes
>
> I second the recommendations of Lowell Gilbert and others not to
> define _BSD_SOURCE or _GNU_SOURCE (especially not _GNU_SOURCE)
> but instead seek alternatives, which are readily available for
> the two functionalities being sought in this case.
>
>> #define _GNU_SOURCE /* necessary for strnlen() in string.h */
>> #define _BSD_SOURCE /* necessary for usleep() in unistd.h */
>> ...all #includes here...
>
> For strnlen(), put an inline definition in a header file:
>
> #ifndef HAVE_strnlen_dot_h_header
> #define HAVE_strnlen_dot_h_header
>
> #include <stddef.h>
>
> static inline size_t
> strnlen( const char *s, size_t n ){
> extern void *memchr( const void *, int, size_t );
> const char *p = memchr( s, 0, n );
> return p ? (size_t){ p-s } : n;
> }
>
> #include <string.h>
>
> #endif
>
> Disclaimer: this code has been compiled but not tested.

strnlen() is specified by POSIX. It might make sense to re-implement it
if your code needs to work on a non-POSIX system (that doesn't also
provide it). Why would you want to do so otherwise?

memchr() is declared in <string.h>. Why would you duplicate its
declaration rather than just using `#include <string.h>`?

[...]

> For usleep(), define an alternate function usnooze(), to be used
> in place of usleep(). In header file usnooze.h:
[snip]

If your code doesn't need to be portable to systems that don't provide
usleep(), you can just use usleep(). If it does, its probably better to
modify the code so it uses nanosleep().

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Effect of CPP tags

<umt4pk$1tg5p$1@dont-email.me>

  copy mid

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

  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: bc...@freeuk.cm (Bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 1 Jan 2024 01:33:38 +0000
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <umt4pk$1tg5p$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me> <umsufv$1snq9$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 1 Jan 2024 01:33:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="28187a935c267aeaaba50f82ab9dacbb";
logging-data="2015417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wPZZVqjfQbM5FzUGf6N8u7SHQSdJtHQQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:z01VUoJmRyvN40MlV5DwlgG/UTE=
In-Reply-To: <umsufv$1snq9$2@dont-email.me>
Content-Language: en-GB
 by: Bart - Mon, 1 Jan 2024 01:33 UTC

On 31/12/2023 23:46, Lawrence D'Oliveiro wrote:
> On Sun, 31 Dec 2023 02:18:25 +0000, Bart wrote:
>
>> This somes my experience of software originating in Linux. This is why
>> Windows had to acquire CYGWIN then MSYS then WSL. You can't build the
>> simplest program without involving half of Linux.
>
> On Linux, we have package managers that only pull in the needed
> dependencies. Windows just seems actively hostile to that kind of
> infrastructure management. If you meant “you can’t build the simplest
> program *on Windows* without involving half of Linux” ... well, that’s
> just a reflection on the deficiencies of Windows. On Linux, you already
> have the *whole* of Linux to start with.

And developers feel it necessary to USE everything that it provides!

I've never managed to build the GMP library on Windows for example (it
only comes as source code), because it requires that 30,000-line bash
script which in turn needs sed and m4 and all the rest.

Why? It's a numeric library. Why should it be dependent on OS?

Or maybe Linux developers NEED all that hand-holding and have no idea
how to build using a bare compiler. Remember that end-users building
such projects are only doing a one-time build to get a working binary.

I have sometimes made my own non-C projects available on Linux. I did
that by transpiling to a single C source file. All you then need to
build it is a C compiler. It would be almost as easy as building
hello.c, except I suspect some don't even know that, since they are used
to 'make'.

> On Linux, we have package managers that only pull in the needed
> dependencies. Windows just seems actively hostile to that kind of

Yeah, I've seen them in action. Sometimes they work, sometimes not. On a
Raspberry Pi, one 'apt-get install' went on for 90 minutes, then it
crashed. Fortunately by then I'd forgotten what it was that I'd been
trying to do.

It seems peculiar to me that you take what I see as a drawback -
excessive, gratuitous dependencies which also make the build process
more complex and slower - and somehow turn that into an advantage.

So any platform that doesn't include all that pointless crap must be at
fault, rather than the developer who is inflicting those needless
dependencies.

Re: Effect of CPP tags

<umt6b8$1tk9o$1@dont-email.me>

  copy mid

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

  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: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 1 Jan 2024 02:00:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <umt6b8$1tk9o$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me>
<pan$750c8$285261e$b7c42f65$7a0431b1@invalid.invalid>
<umq4ra$1dt87$1@dont-email.me> <umq8lh$1eaq0$2@dont-email.me>
<umqfag$1f4km$1@dont-email.me> <umqgf3$1f5qb$1@dont-email.me>
<umqj1h$1fg32$1@dont-email.me> <umsufv$1snq9$2@dont-email.me>
<umt4pk$1tg5p$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 1 Jan 2024 02:00:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="942470baad9a35e821becc4bfe3b8b3b";
logging-data="2019640"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+FHr23Y2B3Kku3Ig4ICpGt"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:MnKdbp+QlOMJe2Wz+H+zpM3thZ0=
 by: Lawrence D'Oliv - Mon, 1 Jan 2024 02:00 UTC

On Mon, 1 Jan 2024 01:33:38 +0000, Bart wrote:

> On 31/12/2023 23:46, Lawrence D'Oliveiro wrote:
>>
>> If you meant “you can’t build the simplest
>> program *on Windows* without involving half of Linux” ... well, that’s
>> just a reflection on the deficiencies of Windows. On Linux, you already
>> have the *whole* of Linux to start with.
>
> And developers feel it necessary to USE everything that it provides!

It’s called “code reuse”. A well-designed package-management system just
makes it so much easier to do.

> I've never managed to build the GMP library on Windows for example (it
> only comes as source code), because it requires that 30,000-line bash
> script which in turn needs sed and m4 and all the rest.
>
> Why? It's a numeric library. Why should it be dependent on OS?

Those are just standard file-manipulation tools that any decent OS should
provide.

> Or maybe Linux developers NEED all that hand-holding and have no idea
> how to build using a bare compiler.

If only you could do that on Windows ... but no. Look at all the C runtime
stuff needed just to build a simple “Hello World” program ... because
Windows automatically assumes that every program must have a GUI.

> Remember that end-users building
> such projects are only doing a one-time build to get a working binary.

They find it easier to do “apt-get install”, or a GUI wrapper around same,
like Synaptic.

Re: Effect of CPP tags

<867cktu6mz.fsf@linuxsc.com>

  copy mid

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

  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: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 18:31:00 -0800
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <867cktu6mz.fsf@linuxsc.com>
References: <umet9d$3hir9$1@dont-email.me> <86bka5uda0.fsf@linuxsc.com> <874jfxvqi0.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="4ad5b29cc5222e274263b40ba81c3fd0";
logging-data="2026768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TNWr6wy5ysMZ4Nergan6bajN0+TpXzXU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:HjdpEMpzV4a7hjD50E2WQiNDoKk=
sha1:BvlFuuJg9jCCc2djTIegXaLnw58=
 by: Tim Rentsch - Mon, 1 Jan 2024 02:31 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>>
>>> This is a CPP question that arose last month. It's not about an
>>> actual issue with the software, just out of curiosity and to be sure
>>> it works reliable (it seemingly does).
>>>
>>> In a C99 program on Linux (Ubuntu) I intended to use usleep() and
>>> then also strnlen().
>>>
>>> When I added usleep() and its include file I got an error and was
>>> asked to define the CPP tag '_BSD_SOURCE'. I did so, and because I
>>> wanted side effects of that tag kept as small as possible I
>>> prepended it just before the respective #include and put it at the
>>> end of my #include list
>>>
>>> ...other #includes...
>>> #define _BSD_SOURCE
>>> #include <unistd.h>
>>>
>>> But as got obvious *that* way there had been side-effects and I
>>> had to put the tag at the beginning of all include files (which
>>> astonished me)
>>>
>>> #define _BSD_SOURCE
>>> #include <unistd.h>
>>> ...other #includes here...
>>>
>>> For the strnlen() function I needed another CPP tag, '_GNU_SOURCE'.
>>> So now I have both CPP tag definitions before the includes
>>
>> I second the recommendations of Lowell Gilbert and others not to
>> define _BSD_SOURCE or _GNU_SOURCE (especially not _GNU_SOURCE)
>> but instead seek alternatives, which are readily available for
>> the two functionalities being sought in this case.
>>
>>> #define _GNU_SOURCE /* necessary for strnlen() in string.h */
>>> #define _BSD_SOURCE /* necessary for usleep() in unistd.h */
>>> ...all #includes here...
>>
>> For strnlen(), put an inline definition in a header file:
>>
>> #ifndef HAVE_strnlen_dot_h_header
>> #define HAVE_strnlen_dot_h_header
>>
>> #include <stddef.h>
>>
>> static inline size_t
>> strnlen( const char *s, size_t n ){
>> extern void *memchr( const void *, int, size_t );
>> const char *p = memchr( s, 0, n );
>> return p ? (size_t){ p-s } : n;
>> }
>>
>> #include <string.h>
>>
>> #endif
>>
>> Disclaimer: this code has been compiled but not tested.
>
> strnlen() is specified by POSIX. It might make sense to
> re-implement it if your code needs to work on a non-POSIX system
> (that doesn't also provide it). Why would you want to do so
> otherwise?

I'm trying to provide a helpful answer to the person I was
responding to, not espouse a philosophical viewpoint. Why do you
feel the need to start a style debate?

> memchr() is declared in <string.h>. Why would you duplicate its
> declaration rather than just using `#include <string.h>`?

I had a specific reason for writing the code the way I did.
It wasn't important to explain that so I didn't.

>> For usleep(), define an alternate function usnooze(), to be used
>> in place of usleep(). In header file usnooze.h:
>
> [snip]
>
> If your code doesn't need to be portable to systems that don't
> provide usleep(), you can just use usleep(). If it does, its
> probably better to modify the code so it uses nanosleep().

Not everyone agrees with that opinion. Again, I'm just trying to
provide an answer helpful to OP, not advance an agenda. Like I
said in the part of my posting that you left out, I don't want to
get involved in a style war. If OP wants to modify his code to
use nanosleep(), I'm fine with that. If want wants to keep using
usleep() or switch to using usnooze(), I'm fine with that too. I
think it's more important in this case to provide options than to
try to change someone's point of view.

Re: Effect of CPP tags

<8634vhu6jy.fsf@linuxsc.com>

  copy mid

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

  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: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Sun, 31 Dec 2023 18:32:49 -0800
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <8634vhu6jy.fsf@linuxsc.com>
References: <umet9d$3hir9$1@dont-email.me> <umk836$ehn5$1@dont-email.me> <iXBjN.109557$p%Mb.36381@fx15.iad> <umms18$sss0$1@dont-email.me> <87frzkvnnk.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="4ad5b29cc5222e274263b40ba81c3fd0";
logging-data="2026768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1812TQNW1IdWPO2El78MzBA20vC/NH0gfY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ijuDCF+1J9d7GR68chC/miqwvQo=
sha1:BBfebxxcY3znsy6F5+oCjaHqUPw=
 by: Tim Rentsch - Mon, 1 Jan 2024 02:32 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> [...]
>
>> BTW, is 'inline' meanwhile C standard? (I know that from C++ but
>> haven't done much C for long now.)
>
> C added inline in C99 (the 1999 edition of the ISO C standard, the same
> one that removed implicit int).
>
> I think C and C++ have subtly different semantics for inline.

I'm not a C++ expert, but as best I can tell C and C++ have
markedly different semantics for what 'inline' does.

Re: Effect of CPP tags

<20231231182912.611@kylheku.com>

  copy mid

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

  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: Effect of CPP tags
Date: Mon, 1 Jan 2024 02:58:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <20231231182912.611@kylheku.com>
References: <umet9d$3hir9$1@dont-email.me> <umlba2$iq0h$3@dont-email.me>
<ummhnp$rf7k$1@dont-email.me> <ummmqe$s4od$1@dont-email.me>
<87o7e8voy1.fsf@nosuchdomain.example.com> <20231229122012.850@kylheku.com>
<umnhtf$103sg$1@dont-email.me> <ums14k$1p0rs$1@dont-email.me>
<ums2al$1p6jm$1@dont-email.me> <20231231104215.299@kylheku.com>
<umsfum$1qttt$2@dont-email.me> <umsoag$1s2bb$1@dont-email.me>
Injection-Date: Mon, 1 Jan 2024 02:58:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="767daa61edebaca5eb1528102f25e053";
logging-data="2155558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HOSIXIrzbQKUeRQWeLfkiB8jceFFJ/fk="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:V3gup5Wfj7GLpaG8upLTnnmHOxk=
 by: Kaz Kylheku - Mon, 1 Jan 2024 02:58 UTC

On 2023-12-31, Bart <bc@freeuk.cm> wrote:
> On 31/12/2023 19:37, Bart wrote:
>> Actually ctags appears to be also part of Windows.
>
> That's not the case, it just happened to be bundled with Windows.

What??? By what system vendor?

You probably installed something that pulled in ctags.

Ctags is of no use to the average Windows user, and I can practically
guarantee you Microsoft has zero interest in it.

Microsoft has replaced this sort of thing with the Language Server
Protocol system, which is integrated into Visual Studio Code and all
sots of language compilers and run times. (Speaking of which, even VSS
doesn't come with Windows, to my knowledge.)

> How does Vim know where in the file to look? The TAGS files I've
> managed > to produce doesn't have that info, and I can't see anything
> in the help to add it.

Entries look like this:

addrinfo stdlib/socket.tl /^(defstruct addrinfo nil$/;" s

symbol[Tab]path[Tab]search command

The ;" is the start of a comment. The comment field contains extension
fields. The letter s is being used to indicate that the identifier is
the name of a structure (a Lisp one, in this case).

If the search command is a regex search, that is advantageous; the
tags file remains usable even when file contents are changing.
It's possible to use hard coded line numbers.

In Vim you can type :help tags-file-format to get documentation about
this.

> How do you get it to look inside header files, or do those have to be
> submitted manually?

ctags -R will process a tree recursively, including any C header files.
However, things that are only declared and not defined in header files,
like function declarations, are not indexed.

Emacs uses a different tag format, by the way, which I referred to
as etags, I think.

In the TXR Lisp ctags generator I used some tricks. Look at this
entry; it relates to the above addrinfo. canonname is a slot in
this structure:

canonname stdlib/socket.tl /^(defstruct addrinfo nil$/;/canonname/;" m struct:addrinfo

The search command contains two searches! First it searches for the
defstruct line. Then from that point it searches forward for canonname.

This is very important. That file contains two structures which have
a canonname slot; a sockaddr structure also has one:

canonname stdlib/socket.tl /^(defstruct sockaddr nil$/;/canonname/;" m struct:sockaddr

Vim will give you both choices and let you pick:

:tj canonname
canonname canonname_s
# pri kind tag file
1 F canonname socket.c
?
canonname_s = intern(lit("canonname"), user_package);
2 F m canonname stdlib/socket.tl
struct:sockaddr
(defstruct sockaddr nil$/;/canonname
3 F m canonname stdlib/socket.tl
struct:addrinfo
(defstruct addrinfo nil$/;/canonname

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Effect of CPP tags

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

  copy mid

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

  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: Effect of CPP tags
Date: Sun, 31 Dec 2023 19:08:57 -0800
Organization: None to speak of
Lines: 107
Message-ID: <87zfxpu4vq.fsf@nosuchdomain.example.com>
References: <umet9d$3hir9$1@dont-email.me> <86bka5uda0.fsf@linuxsc.com>
<874jfxvqi0.fsf@nosuchdomain.example.com> <867cktu6mz.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5cfe2e3f2648fa7c3f92bc4f108bd948";
logging-data="2158826"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LyCyx4x+Okph8lA0ZnrhX"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:TSvSiszLfq4PO0oWw+XXxrt1oqc=
sha1:5xx8QOAIi2Z2Lc4GZxhP96qZTg4=
 by: Keith Thompson - Mon, 1 Jan 2024 03:08 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>>>
>>>> This is a CPP question that arose last month. It's not about an
>>>> actual issue with the software, just out of curiosity and to be sure
>>>> it works reliable (it seemingly does).
>>>>
>>>> In a C99 program on Linux (Ubuntu) I intended to use usleep() and
>>>> then also strnlen().
>>>>
>>>> When I added usleep() and its include file I got an error and was
>>>> asked to define the CPP tag '_BSD_SOURCE'. I did so, and because I
>>>> wanted side effects of that tag kept as small as possible I
>>>> prepended it just before the respective #include and put it at the
>>>> end of my #include list
>>>>
>>>> ...other #includes...
>>>> #define _BSD_SOURCE
>>>> #include <unistd.h>
>>>>
>>>> But as got obvious *that* way there had been side-effects and I
>>>> had to put the tag at the beginning of all include files (which
>>>> astonished me)
>>>>
>>>> #define _BSD_SOURCE
>>>> #include <unistd.h>
>>>> ...other #includes here...
>>>>
>>>> For the strnlen() function I needed another CPP tag, '_GNU_SOURCE'.
>>>> So now I have both CPP tag definitions before the includes
>>>
>>> I second the recommendations of Lowell Gilbert and others not to
>>> define _BSD_SOURCE or _GNU_SOURCE (especially not _GNU_SOURCE)
>>> but instead seek alternatives, which are readily available for
>>> the two functionalities being sought in this case.
>>>
>>>> #define _GNU_SOURCE /* necessary for strnlen() in string.h */
>>>> #define _BSD_SOURCE /* necessary for usleep() in unistd.h */
>>>> ...all #includes here...
>>>
>>> For strnlen(), put an inline definition in a header file:
>>>
>>> #ifndef HAVE_strnlen_dot_h_header
>>> #define HAVE_strnlen_dot_h_header
>>>
>>> #include <stddef.h>
>>>
>>> static inline size_t
>>> strnlen( const char *s, size_t n ){
>>> extern void *memchr( const void *, int, size_t );
>>> const char *p = memchr( s, 0, n );
>>> return p ? (size_t){ p-s } : n;
>>> }
>>>
>>> #include <string.h>
>>>
>>> #endif
>>>
>>> Disclaimer: this code has been compiled but not tested.
>>
>> strnlen() is specified by POSIX. It might make sense to
>> re-implement it if your code needs to work on a non-POSIX system
>> (that doesn't also provide it). Why would you want to do so
>> otherwise?
>
> I'm trying to provide a helpful answer to the person I was
> responding to, not espouse a philosophical viewpoint. Why do you
> feel the need to start a style debate?

I don't. I simply asked you a question. You've refused to answer
it, and I won't waste my time asking again.

>> memchr() is declared in <string.h>. Why would you duplicate its
>> declaration rather than just using `#include <string.h>`?
>
> I had a specific reason for writing the code the way I did.
> It wasn't important to explain that so I didn't.

Unsurprisingly, you refuse to do so even when asked directly.

>>> For usleep(), define an alternate function usnooze(), to be used
>>> in place of usleep(). In header file usnooze.h:
>>
>> [snip]
>>
>> If your code doesn't need to be portable to systems that don't
>> provide usleep(), you can just use usleep(). If it does, its
>> probably better to modify the code so it uses nanosleep().
>
> Not everyone agrees with that opinion. Again, I'm just trying to
> provide an answer helpful to OP, not advance an agenda. Like I
> said in the part of my posting that you left out, I don't want to
> get involved in a style war. If OP wants to modify his code to
> use nanosleep(), I'm fine with that. If want wants to keep using
> usleep() or switch to using usnooze(), I'm fine with that too. I
> think it's more important in this case to provide options than to
> try to change someone's point of view.

As usual, you vaguely denigrate my opinion without sharing your own.
It's boring.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */


devel / comp.lang.c / Re: Effect of CPP tags

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor