Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Meta

Default Rules: Extensions

+6
−0

Since there have been some discussions about the use of GCC extensions, I decided to make a default-rules post about it. How should we deal with compiler extensions to languages?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

3 answers

+7
−0

The answer header must specify the minimum implementation & environment required

If there are multiple implementations of a language and an answer depends on features of one, it must be specified. Otherwise, it can just specify the language.

That specification can be done mostly in any form, as long as it's complete (or unspecified things are the default). In general, there shouldn't be a need to specify a precise version of an implementation, but if there's explicit reliance on it, it should be noted too.

For example, "C (gcc)" specifies that gcc must be used, with the default settings. "C (clang 12) -std=c11 + boost" means clang-12 with the "ISO C 2011" standard and the boost library. "C" alone would mean any implementation that follows the standard. (whether a standard can be considered an implementation by itself is a separate question)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−1

The C (gcc) implies extensions - it will only work with that specific compiler under it's default setting GNU17 (equivalent to -std=gnu17), which is mostly a superset of standard C. This also includes a number of POSIX functions.

Another option is standard C, meaning no extensions and no constraint or syntax violations. This would be equivalent to gcc -std=c17 -pedantic-errors. As a subset of standard C, there is yet another option: strictly conforming standard C, meaning there can also be no poorly-defined behavior.

The definition of a strictly conforming program can be found in C17 4/5:

A strictly conforming program shall use only those features of the language and library specified in this International Standard. It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.

Solutions in standard C and/or strictly conforming should be labelled as such by the poster. Otherwise, the default behavior of the specific compiler with no options passed to it is assumed to apply.

C++ (g++) behaves mostly the same, though in C++ there's also the boost library which has to be included explicitly. I think boost is to be regarded as any 3rd party lib and solutions using it will then be C++ with boost.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−1

Implementation defines the language, so if you use extensions to a language, you should add + ... extensions to the header.

E.g. for a C post using gcc extensions, the header begin with

# C (gcc) + gcc extensions
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

I disagree (1 comment)

Sign up to answer this question »