Dlaczego gcc zezwala na deklaracje extern typu void (non-pointer)?
Dlaczego gcc zezwala na deklaracje extern typu void? Czy to rozszerzenie lub standard C? Czy są do tego dopuszczalne zastosowania?
Zgaduję, że jest to rozszerzenie, ale nie znalazłem go w:
http://gcc.gnu.org/onlinedocs/gcc-4.3.6/gcc/C-Extensions.html
<code>$ cat extern_void.c extern void foo; /* ok in gcc 4.3, not ok in Visual Studio 2008 */ void* get_foo_ptr(void) { return &foo; } $ gcc -c extern_void.c # no compile error $ gcc --version | head -n 1 gcc (Debian 4.3.2-1.1) 4.3.2 </code>
Definiowanie foo jako typu void jest oczywiście błędem kompilacji:
<code>$ gcc -c -Dextern= extern_void.c extern_void.c:1: error: storage size of ‘foo’ isn’t known </code>
Dla porównania Visual Studio 2008 podaje błąd w deklaracji extern:
<code>$ cl /c extern_void.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. extern_void.c extern_void.c(1) : error C2182: 'foo' : illegal use of type 'void' </code>