Hi Rémi,

On Wed, Nov 30, 2016 at 1:46 PM, Rémi Denis-Courmont <[email protected]> wrote:
>
> I´d hazard a guess that in C11 mode, you should use the compiler´s
> <stdatomic.h>, rather than libav´s variant of my compatibility wrapper.
>
> At least, I did not intend it to be used in C11 mode.

I am using gcc 4.8.4 on Ubuntu 14.04 LTS. It doesn't have the
<stdatomic.h> header. This matches what is published in the GCC C11
status page that -std=c11 is available in GCC 4.7 and _Atomic and
stdatomic.h are available in GCC 4.9:

https://gcc.gnu.org/wiki/C11Status

Here is the transcript of my experiment:

==========
$ cat /etc/lsb-release
# $Id: 
//depot/google3/googledata/corp/puppet/goobuntu/common/modules/base/templates/lsb-release.erb#1
$
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
GOOGLE_CODENAME=trusty
GOOGLE_ID=Goobuntu
GOOGLE_RELEASE="14.04 201611TD2-2"
GOOGLE_ROLE=desktop
GOOGLE_TRACK=stable
$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat foo.c
#include <stdatomic.h>

int main()
{
    atomic_int i;
    atomic_store(&i, 0);
    return 0;
}
$ gcc -Wall -std=c11 foo.c
foo.c:1:23: fatal error: stdatomic.h: No such file or directory
 #include <stdatomic.h>
                       ^
compilation terminated.
$
==========

The reason I ran into this problem is that I added a
atomic_compare_exchange_strong_explicit() call to libavutil/cpu.c and
got a compilation error:

==========
$ make V=1
gcc -I. -I. -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-I./compat/atomics/gcc -DZLIB_CONST -DHAVE_AV_CONFIG_H -std=c11
-fomit-frame-pointer -pthread -g -Wdeclaration-after-statement -Wall
-Wdisabled-optimization -Wpointer-arith -Wredundant-decls
-Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes
-Wstrict-prototypes -Wno-parentheses -Wno-switch
-Wno-format-zero-length -Wno-pointer-sign -O3 -fno-math-errno
-fno-signed-zeros -fno-tree-vectorize
-Werror=implicit-function-declaration -Werror=missing-prototypes
-Werror=return-type -Werror=declaration-after-statement -Werror=vla
-Werror=format-security -Wno-maybe-uninitialized  -MMD -MF
libavutil/cpu.d -MT libavutil/cpu.o -c -o libavutil/cpu.o
libavutil/cpu.c
libavutil/cpu.c: In function ‘av_get_cpu_flags’:
libavutil/cpu.c:67:9: error: implicit declaration of function ‘typeof’
[-Werror=implicit-function-declaration]
         atomic_compare_exchange_strong_explicit(&cpu_flags, &old_flags, flags,
         ^
In file included from libavutil/cpu.c:20:0:
./compat/atomics/gcc/stdatomic.h:116:20: error: expected ‘;’ before ‘_exp’
     typeof(object) _exp = (expected);                               \
                    ^
./compat/atomics/gcc/stdatomic.h:123:5: note: in expansion of macro
‘atomic_compare_exchange_strong’
     atomic_compare_exchange_strong(object, expected, desired)
     ^
libavutil/cpu.c:67:9: note: in expansion of macro
‘atomic_compare_exchange_strong_explicit’
         atomic_compare_exchange_strong_explicit(&cpu_flags, &old_flags, flags,
         ^
...
==========

Wan-Teh Chang
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to