Analog GCC '-ffshort-double' in Clang - c

There is an option '-fshort-double' in GCC, Clang does not understand it. Is there some analog of this option for Clang 3.7 ?

in looking at the web page: https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html#Option-Summary,
there is no -fshort-double option in gcc.
therefore, the option is not valid to begin with.
suggest removing that option when changing to clang

Related

Is there a command line involving gcc to know which --std=xxx it is using?

I can choose to call
gcc --std=c99 toto.c -o toto.elf
But in my case, I would like to know which --std is used by default when calling
gcc toto.c -o toto.elf
Note for closing request:
I refute the idea that this topic is a duplicate, in fact, what I want is not only knowing what the default --std is but also what --std is currently used and how make difference between std=gnu11 and std=c11.
Sure that my first post was leading people in error.
i found this gcc -dM -E - < /dev/null | grep 'STDC_VERSION'
Everything prior version 5.0.0 has -std=gnu90 as default.
Everything between version 5.0.0 and 8.0.0 has -std=gnu11 as default.
Everything past 8.0.0 has -std=gnu17 as default.
So you only need to check --version. However, the __STDC_VERSION__ should also correspond to the -std=cxx even when compiling with GNU extensions.

What are the set of options to pass to gcc when compiling C89 code

I know about -ansi -pedantic-errors
Is there any other options to be as defensive as possible, in my code? I mean I don't want to miss any warnings or anything.
If you don't want to miss any warnings or anything then, just use -std= switch. Use `-std=c89. Link gcc docs provided by GNU is having the information about different switch available. If you are using any other compiler then see the respective documents.

Compile with Clang and use GETTEXT

I have a automake enabled project which I would like to compile with clang. I have added a configure option to enable clang:
AC_ARG_ENABLE([clang],
[AS_HELP_STRING([--enable-clang],[use clang instead of gcc as C compiler.])])
#Use C99 compilation mode
if test "x$enable_clang" = "xyes"; then
# clang uses c99 mode by default, so we just set CC to clang and we are done
CC="clang";
else
# We do not need to set CC as the default is gcc, but we need to set it to
# use C99 compilation mode
CFLAGS="$CFLAGS -std=c99";
fi
Further up in the file I have also the following two macros, to enable gettext functionality:
AM_GNU_GETTEXT_VERSION([0.18.1])
AM_GNU_GETTEXT([external])
If these two macros are present then configure ignores that the CC variable is set to clang and falls back to gcc. I have to comment out the gettext macros and then clang is used.
Obviously there is some problem with GETTEXT and clang. Am I using the wrong macro, or is clang not able to use the gnu gettext library? How can I fix this?
Have you tried to set CC to clang before you check for libraries (like gettext)? – Some programmer dude
Nice that worked. – lanoxx

How do I compile in Xcode using gcc with -ansi -pedantic?

I need to compile a code written in C using gcc (in Xcode) with flag options -ansi -pedantic. I know how to change the compiler to gcc, however I don't know how to change the flags.
Thanks in advance.
Use the Other C Flags build setting to add compiler flags that aren't available in Xcode's build settings editor.

How to enable c11 on later versions of gcc?

I currently use gcc 4.6.3. My understanding is that gcc by default uses the gnu89 standard and I would like to enable C11, the latest C standard. I tried:
[pauldb#pauldb-laptop test ]$ gcc -std=c11 -o test test.c
cc1: error: unrecognised command line option ‘-std=c11’
I replaced c11 with gnu11 and I get the same error. What is the correct way to enable the latest C standard for gcc?
(Note: I'm interested in the latest C standard and not the latest C++ one.)
The correct option is -std=c11.
However, it is not available in gcc 4.6. You need at least gcc 4.7 to have this option supported. In some older versions like gcc 4.6, the option -std=c1x was available with experimental (i.e., very limited) support of C11.
Note that the current version of gcc is gcc 8.2.
Just to let you know GCC 4.9.x has far more complete support than older versions. If you really need to use this feature, please switch to anything 4.8+
Here is the support status -- https://gcc.gnu.org/wiki/C11Status
gcc 5.2.0 works with command line option ‘-std=c11’
Inside a .spec file :
%define gcc_ver %(if [[ $(gcc -dumpversion) > 4.7 ]]; then echo 1; else echo 0; fi)
# Do we use c11 ?
%if 0%{?gcc_ver} < 1
%global std_c11 0
%else
%global std_c11 1
%endif
# if the configure of the package supports it add :
%if %{std_c11}
--enable-cxx11 \
%endif

Resources