[petsc-dev] Request for comments: allow C99 internally

Jeff Hammond jeff.science at gmail.com
Wed Mar 11 00:01:24 CDT 2020


I wonder if it is not more useful to talk in terms of C11 features.  Unlike
C99, C11 makes VLAs optional via __STDC_NO_VLA__, so you have a
standardized way of expressing the subset of C11 that is compatible with
C++11.  __STDC_NO_ATOMICS__ and __STDC_NO_THREADS__ play a similar role.

Of course, some compilers refuse to use these properly, so PETSc will have
to check compiler support directly rather than trusting macros, but that is
nothing new and Jed (rightly) doesn't trust such compiler macros anyways.
I merely suggest that the macros correspond to an ISO C language definition
for describing the portable subset in a way that C99 cannot.

Jeff

On Mon, Mar 9, 2020 at 11:48 AM Lisandro Dalcin <dalcinl at gmail.com> wrote:

>
>
> On Sat, 7 Mar 2020 at 08:48, Jed Brown <jed at jedbrown.org> wrote:
>
>> I have a question for petsc-dev: Do you know anyone who needs to build
>> PETSc with a compiler that doesn't support variadic macros and for-loop
>> declarations?  (Both of these are in C99 and C++11, and supported by all
>> tested configurations including compilers that don't fully implement
>> these standards.)  Both MPICH and Open MPI use variable-length arrays
>> and for-loop declarations, so you'd be hard-pressed building a modern
>> stack with such a compiler.  I'm not proposing that we put these macros
>> unguarded into the public headers, so a user of PETSc could still build
>> with -std=c89 and the like.
>>
>>
> Definitely +1 for variadic macros and for-loop declarations, but not VLAs.
>
>
> --
> Lisandro Dalcin
> ============
> Research Scientist
> Extreme Computing Research Center (ECRC)
> King Abdullah University of Science and Technology (KAUST)
> http://ecrc.kaust.edu.sa/
>


-- 
Jeff Hammond
jeff.science at gmail.com
http://jeffhammond.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200310/c4f078d5/attachment-0001.html>


More information about the petsc-dev mailing list