G++: /usr/include/stdio.h:30: error: expected constructor, destructor, or type conversion before 'extern'

Доброе утро!

Кто знает, откуда берется ошибка, указанная в теме, и как с ней бороться? казалось бы, stdio.h --- стандартная библиотека, в ней не должно быть ошибок...

Я погуглил на эту тему, но ответов не нашел.

Не всегда

Не всегда ошибка там, где говорит компилятор, нередко она где-то раньше.
Так что покажи лучше свой исходник, компиляция которого приводит к такой ошибке.
Вот тут:
http://www.mail-archive.com/glob2-devel@nongnu.org/msg02042.html
винят gcc-4.

Не gcc-4

Я натыкался уже на эту страничку, но здесь проблема не в gcc-4
На gcc-3 тоже пробовал, та же история.
Может, параметры компиляции не те:

CC=g++  -v
INCLUDE = -I/usr/include/libxml2 -I/usr/lib/glib/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
xml_client.o: xml_client.c
	$(CC) $(INCLUDE) -c xml_client.c $(LIBS_STRUCTOR)

Мне кажется, я что-то не указал для используемых библиотек, иначе странно иметь столько бибиотечных ошибок. Привожу кусок кода с заголовками (весь файл большой):

#include <stdio.h>
#include <pcap.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h> 
#include <signal.h>
#include <math.h>
#include <ctype.h>
#include <pcap-namedb.h>
#include <netdb.h> 
#include <syslog.h>
#include <sys/time.h>
#include <glib.h>
#include <libxml/tree.h>

На самом деле ошибок выдается больше,я указал в теме только первую. Вот фрагмент вывода команды make:

Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1-r1/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,objc,obj-c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1-r1)
 /usr/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -quiet -v -I/usr/include/pcap -I/usr/include/libxml2 -I/usr/lib/glib/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_GNU_SOURCE xml_client.c -quiet -dumpbase xml_client.c -mtune=pentiumpro -auxbase xml_client -version -o /tmp/cckDjhpa.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/include/pcap"
ignoring nonexistent directory "/usr/lib/glib/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/libxml2
 /usr/include/glib-2.0
 /usr/lib/glib-2.0/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/i686-pc-linux-gnu
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/backward
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include
 /usr/include
End of search list.
GNU C++ version 4.1.1 (Gentoo 4.1.1-r1) (i686-pc-linux-gnu)
	compiled by GNU C version 4.1.1 (Gentoo 4.1.1-r1).
GGC heuristics: --param ggc-min-expand=90 --param ggc-min-heapsize=112935
Compiler executable checksum: 9d07bbb36cc733c6f3a1306c8aa263a2
/usr/include/stdio.h:30: error: expected constructor, destructor, or type conversion before 'extern'
/usr/include/sys/types.h:35: error: '__u_char' does not name a type
/usr/include/sys/types.h:36: error: '__u_short' does not name a type
/usr/include/sys/types.h:37: error: '__u_int' does not name a type
/usr/include/sys/types.h:38: error: '__u_long' does not name a type
/usr/include/sys/types.h:39: error: '__quad_t' does not name a type
/usr/include/sys/types.h:40: error: '__u_quad_t' does not name a type
/usr/include/sys/types.h:41: error: '__fsid_t' does not name a type
/usr/include/sys/types.h:46: error: '__loff_t' does not name a type
/usr/include/sys/types.h:50: error: '__ino_t' does not name a type
/usr/include/sys/types.h:57: error: '__ino64_t' does not name a type
/usr/include/sys/types.h:62: error: '__dev_t' does not name a type
/usr/include/sys/types.h:67: error: '__gid_t' does not name a type
/usr/include/sys/types.h:72: error: '__mode_t' does not name a type
/usr/include/sys/types.h:77: error: '__nlink_t' does not name a type
/usr/include/sys/types.h:82: error: '__uid_t' does not name a type
/usr/include/sys/types.h:88: error: '__off_t' does not name a type
/usr/include/sys/types.h:95: error: '__off64_t' does not name a type
/usr/include/sys/types.h:100: error: '__pid_t' does not name a type
/usr/include/sys/types.h:105: error: '__id_t' does not name a type
/usr/include/sys/types.h:110: error: '__ssize_t' does not name a type
/usr/include/sys/types.h:116: error: '__daddr_t' does not name a type
/usr/include/sys/types.h:117: error: '__caddr_t' does not name a type
/usr/include/sys/types.h:123: error: '__key_t' does not name a type
/usr/include/time.h:61: error: '__clock_t' does not name a type
/usr/include/time.h:77: error: '__time_t' does not name a type
/usr/include/time.h:93: error: '__clockid_t' does not name a type
/usr/include/time.h:105: error: '__timer_t' does not name a type
/usr/include/sys/types.h:137: error: '__useconds_t' does not name a type
/usr/include/sys/types.h:141: error: '__suseconds_t' does not name a type
/usr/include/time.h:123: error: '__time_t' does not name a type
/usr/include/bits/time.h:71: error: '__time_t' does not name a type
/usr/include/bits/time.h:72: error: '__suseconds_t' does not name a type
/usr/include/sys/types.h:228: error: '__blksize_t' does not name a type
/usr/include/sys/types.h:235: error: '__blkcnt_t' does not name a type
/usr/include/sys/types.h:239: error: '__fsblkcnt_t' does not name a type
/usr/include/sys/types.h:243: error: '__fsfilcnt_t' does not name a type
/usr/include/sys/types.h:262: error: '__blkcnt64_t' does not name a type
/usr/include/sys/types.h:263: error: '__fsblkcnt64_t' does not name a type
/usr/include/sys/types.h:264: error: '__fsfilcnt64_t' does not name a type
/usr/include/pcap-bpf.h:68: error: 'u_int' does not name a type
/usr/include/pcap-bpf.h:90: error: 'u_int' does not name a type
/usr/include/pcap-bpf.h:106: error: 'u_short' does not name a type
/usr/include/pcap-bpf.h:107: error: 'u_short' does not name a type
/usr/include/pcap-bpf.h:668: error: 'u_short' does not name a type
/usr/include/pcap-bpf.h:669: error: 'u_char' does not name a type
/usr/include/pcap-bpf.h:670: error: 'u_char' does not name a type
/usr/include/pcap-bpf.h:682: error: 'u_int' does not name a type
/usr/include/pcap.h:114: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:115: error: 'u_short' does not name a type
/usr/include/pcap.h:116: error: 'u_short' does not name a type
/usr/include/pcap.h:118: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:119: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:120: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:136: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:137: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:144: error: 'u_int' does not name a type
/usr/include/pcap.h:145: error: 'u_int' does not name a type
/usr/include/pcap.h:146: error: 'u_int' does not name a type
/usr/include/pcap.h:193: error: 'bpf_u_int32' does not name a type
/usr/include/pcap.h:209: error: typedef 'pcap_handler' is initialized (use __typeof__ instead)
/usr/include/pcap.h:209: error: 'u_char' was not declared in this scope
/usr/include/pcap.h:209: error: expected primary-expression before ',' token
/usr/include/pcap.h:209: error: expected primary-expression before 'const'
/usr/include/pcap.h:210: error: expected primary-expression before 'const'
/usr/include/pcap.h:213: error: 'bpf_u_int32' has not been declared
/usr/include/pcap.h:213: error: 'bpf_u_int32' has not been declared
/usr/include/pcap.h:217: error: 'FILE' was not declared in this scope
/usr/include/pcap.h:217: error: expected primary-expression before ',' token
/usr/include/pcap.h:217: error: expected primary-expression before 'char'
/usr/include/pcap.h:217: error: initializer expression list treated as compound expression
/usr/include/pcap.h:219: error: 'u_char' has not been declared
/usr/include/pcap.h:220: error: 'u_char' has not been declared
/usr/include/pcap.h:221: error: expected initializer before '*' token
/usr/include/pcap.h:223: error: expected ',' or '...' before '*' token
/usr/include/pcap.h:231: error: 'size_t' has not been declared
/usr/include/pcap.h:232: error: expected ',' or '...' before '*' token
/usr/include/pcap.h:236: error: 'bpf_u_int32' has not been declared
/usr/include/pcap.h:238: error: 'bpf_u_int32' has not been declared
/usr/include/pcap.h:252: error: expected constructor, destructor, or type conversion before '*' token
/usr/include/pcap.h:256: error: 'FILE' has not been declared
/usr/include/pcap.h:257: error: expected constructor, destructor, or type conversion before '*' token
/usr/include/pcap.h:261: error: variable or field 'pcap_dump' declared void
/usr/include/pcap.h:261: error: 'u_char' was not declared in this scope
/usr/include/pcap.h:261: error: expected primary-expression before ',' token
/usr/include/pcap.h:261: error: expected primary-expression before 'const'
/usr/include/pcap.h:261: error: expected primary-expression before 'const'
/usr/include/pcap.h:261: error: initializer expression list treated as compound expression
/usr/include/pcap.h:269: error: 'u_int' does not name a type
/usr/include/stdlib.h:140: error: 'size_t' does not name a type
/usr/include/stdlib.h:455: error: 'size_t' has not been declared
/usr/include/stdlib.h:485: error: 'size_t' has not been declared
/usr/include/stdlib.h:589: error: 'size_t' was not declared in this scope
/usr/include/stdlib.h:589: error: expected ',' or ';' before 'throw'
/usr/include/stdlib.h:591: error: 'size_t' was not declared in this scope
/usr/include/stdlib.h:591: error: 'size_t' was not declared in this scope
/usr/include/stdlib.h:591: error: initializer expression list treated as compound expression
/usr/include/stdlib.h:592: error: expected ',' or ';' before 'throw'
/usr/include/stdlib.h:600: error: 'size_t' has not been declared
/usr/include/alloca.h:33: error: 'size_t' was not declared in this scope
/usr/include/alloca.h:33: error: expected ',' or ';' before 'throw'
/usr/include/stdlib.h:617: error: 'size_t' was not declared in this scope
/usr/include/stdlib.h:617: error: expected ',' or ';' before 'throw'
/usr/include/stdlib.h:622: error: 'size_t' has not been declared
/usr/include/stdlib.h:622: error: 'size_t' has not been declared
/usr/include/stdlib.h:776: error: 'size_t' has not been declared
/usr/include/stdlib.h:776: error: 'size_t' has not been declared
/usr/include/stdlib.h:781: error: 'size_t' has not been declared
/usr/include/stdlib.h:781: error: 'size_t' has not been declared
/usr/include/stdlib.h:854: error: 'size_t' has not been declared
/usr/include/stdlib.h:857: error: 'size_t' has not been declared
/usr/include/stdlib.h:861: error: 'size_t' has not been declared
/usr/include/stdlib.h:865: error: 'size_t' has not been declared
/usr/include/stdlib.h:874: error: 'size_t' has not been declared
/usr/include/stdlib.h:878: error: 'size_t' has not been declared
/usr/include/stdlib.h:885: error: 'size_t' does not name a type
/usr/include/stdlib.h:888: error: 'size_t' does not name a type
/usr/include/stdlib.h:951: error: 'size_t' has not been declared

Проблема в инклудах GLib

-I/usr/lib/glib/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

всё дело в том, что glib.h

из -I/usr/include/glib-2.0

цепляет не свой glibconfig.h (из -I/usr/lib/glib/include)
а первой версии glib,

убери -I/usr/lib/glib/include

и всё соберётся.

Это была глупая ошибка,

какая-то опечатка в тексте.

Спасибо KiberGus за совет!

Настройки просмотра комментариев

Выберите нужный метод показа комментариев и нажмите "Сохранить установки".