tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Some rambling about strdup()'s standard and other standards issues



At Thu, 01 May 2025 19:53:07 -0400, Greg Troxel <gdt%lexort.com@localhost> wrote:
Subject: Re: Some rambling about strdup()'s standard and other standards issues
>
> "Greg A. Woods" <woods%planix.ca@localhost> writes:
>
> > Should NetBSD kill off _NETBSD_SOURCE if __STRICT_ANSI__ is defined?  Is
> > that really a good hint that the code will also define something like
> > _POSIX_SOURCE if it also wants to use POSIX "extensions"?
>
> No, because I see "really comply with the C standard" as being separate
> from "hide OS features not required by CNN".   To me the point of
> __STRICT_ANSI__ is to throw errors on gnu extensions to C, so that the
> code would build with some other compiler.

"Strictly" speaking though the C Standard includes all the functions
(and typedefs, even the names of the header files, and so on), so that
would imply that all POSIX-only stuff, and all system-specific stuff, is
also all just more extensions.

Where to draw the line, and how to deal with different systems drawing
it differently?

Also, couldn't another use of __STRICT_ANSI__ be to allow workarounds to
extensions to be put in place too?  Same idea though -- to allow the
code to build and work with some other compiler (and libraries).

	#ifdef __STRICT_ANSI__
	# define strdup(s)       strcpy(malloc(strlen(s) + 1), s)
	#endif

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpQDjBcV6lgs.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index