How to fix ""/usr/include/string.h", line 44: syntax error at token '__dest'" when using cproto - c

I am compiling a C program on CentOS 6.8 and I see a lot of syntax errors in gcc include header files at token '???', but it can generate the binary eventually.
The cproto version I am using is 4.6 and I have tried gcc 4.4.7 and gcc 5.4. I am confused what went wrong with my /usr/include/*.h. Any help would be really appreciated.
Here is part of the log:
cproto -D__extension__=" " -DCPROTO -S -f 2 -I. -I/home/XXX/include -o test.pl test.c
"/usr/include/stdarg.h", line 40: syntax error at token '__builtin_va_list'
"/usr/include/libio.h", line 491: syntax error at token '__gnuc_va_list'
"/usr/include/stdio.h", line 197: syntax error at token '__asm__'
"/usr/include/stdio.h", line 282: syntax error at token '__filename'
......
"/usr/include/stdio.h", line 734: syntax error at token '__ptr'
"/usr/include/stdio.h", line 779: syntax error at token '__asm__'
"/usr/include/stdio.h", line 801: syntax error at token '__stream'
"/usr/include/stdio.h", line 803: syntax error at token '__asm__'
"/usr/include/stdlib.h", line 165: syntax error at token '__nptr'
......
"/usr/include/stdlib.h", line 210: syntax error at token '__nptr'
"/usr/include/stdlib.h", line 215: syntax error at token '__nptr'
"/usr/include/sys/select.h", line 109: syntax error at token '__readfds'
"/usr/include/stdlib.h", line 360: syntax error at token '__buf'
"/usr/include/stdlib.h", line 366: syntax error at token '__statebuf'
"/usr/include/stdlib.h", line 371: syntax error at token '__statebuf'
......
"/usr/include/string.h", line 44: syntax error at token '__dest'
"/usr/include/string.h", line 57: syntax error at token '__dest'
......
"/usr/include/fcntl.h", line 209: syntax error at token '__asm__'
"/usr/include/sys/stat.h", line 219: syntax error at token '__file'
"/usr/include/sys/stat.h", line 222: syntax error at token '__asm__'
"/usr/include/sys/stat.h", line 269: syntax error at token '__file'
"/usr/include/sys/stat.h", line 412: syntax error at token '__asm__'
"/usr/include/sys/stat.h", line 415: syntax error at token '__asm__'
"/usr/include/sys/stat.h", line 418: syntax error at token '__asm__'
"/usr/include/sys/stat.h", line 421: syntax error at token '__asm__'
gcc -g -c -m64 -gdwarf-2 -g -D__USE_XOPEN2K8 -std=gnu89 -DTPI_DEBUG -c -I. -I/home/XXX/include ./test.c

Related

Simple hello world program produces: ld: 1: Syntax error: ")" unexpected

#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
When I want to compile this sample code with gcc aa.c -o tt I get an error:
/usr/bin/ld: 1: Syntax error: ")" unexpected
collect2: error: ld returned 2 exit status
I got this error when making a repo to install and I got the below error in the log file (a portion of the file).
gcc version 7.5.0 (Ubuntu 7.5.0-6ubuntu2)
configure:3674: $? = 0
configure:3663: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3674: $? = 1
configure:3663: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:3674: $? = 1
configure:3694: checking whether the C compiler works
configure:3716: gcc conftest.c >&5
/usr/bin/ld: 1: Syntax error: ")" unexpected
collect2: error: ld returned 2 exit status
configure:3720: $? = 1

How should I compile this old code with cc

I'm trying to compile source code, that from 2001, in Ubuntu 18.04.2 LTS. But, I got the errors below and actually don't know how I have to change the compiling code. Can you help me for compiling this code?
Suggested compilation part from the program
SUGGESTED COMPILATION COMMAND LINE (FOR A DEC-ALPHA CC-COMPILER):
cc -lm -fast -tune host -arch host -assume whole_program \
-o mol_volume mol_volume.c
When I tried this code, errors;
cc: error: host: No such file or directory
cc: error: host: No such file or directory
cc: error: whole_program: No such file or directory
cc: error: unrecognized command line option ‘-fast’; did you mean ‘-Ofast’?
cc: error: unrecognized command line option ‘-tune’; did you mean ‘-mtune=’?
cc: error: unrecognized command line option ‘-arch’; did you mean ‘-march=’?
cc: error: unrecognized command line option ‘-assume’; did you mean ‘-msse’?
Then, I changed -fast, -tune, -arch, -assume flags with -Ofast, -mtune=native, -march=native, -msse then add the path the for the directory part of the errors.
cc -lm -Ofast -mtune=native -march=native -msse /mypath/ -o mol_volume mol_volume.c
Then, I got that error;
mol_volume.c: In function ‘main’:
mol_volume.c:235:10: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
while( gets(s) ) {
^~~~
fgets
mol_volume.c:311:26: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
printf("WARNING: the %i-th atom of the pdb file %s has an unknown chemical type %s.\n",
~^
%li
i+1, pdb_name, atom_type);
~~~
/usr/bin/ld: cannot find .: File format not recognized
collect2: error: ld returned 1 exit status
You can access the source code via this link;
Source Code
My PC info:
Operation System: Ubuntu 18.04.2 LTS
Kernel ver.: 4.15.0-50-generic
GCC ver.: 7.4.0
gets was removed in C11. Compile with gcc -o mol_volume -Wall -std=c99 -mtune=native -O3 mol_volume.c -lm.
It will work but you should fix the code to remove all the warnings.

Creating a shared library by Eclipse CDT

I am getting this error each time and i do not not what is happening .. can anyone help please ?
#Mike Kinghan this is the new error
08:21:40 **** Incremental Build of configuration Debug for project 5exe ****
make all
Building file: ../5exe.c
Invoking: GCC C Compiler
gcc -I"C:\Users\Dylan Galea\workspace\5\source" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"5exe.d" -MT"5exe.o" -o "5exe.o" "../5exe.c"
../5exe.c: In function 'main':
../5exe.c:42:10: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
char temp; //temporary storage to remove the extra ( character
^
Finished building: ../5exe.c
Building target: 5exe.exe
Invoking: MinGW C Linker
gcc -L"C:\Users\Dylan Galea\workspace\5\Debug -o "5exe.exe" ./5exe.o -l5
/usr/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
makefile:29: recipe for target '5exe.exe' failed
make: *** [5exe.exe] Error 258
08:21:40 Build Finished (took 463ms)
Your source code (which you didn't post) has an unterminated string literal, something like
printf("example text %d with an integer , 4);
/* ^ missing `"' /*
The backslash ('\') is an escape-character for the shell (/usr/bin/sh). So in this line:
gcc -I"C:\Users\Dylan Galea\workspace\5\source\" -O0 -g3 -Wall -c -fmessage- length=0 -MMD -MP -MF"5exe.d" -MT"5exe.o" -o "5exe.o" "../5exe.c"
the backslash '\' that follows source escapes the following ", and the string
"C:\Users\Dylan Galea\workspace\5\source\" is parsed as having unbalanced quotes.
Do one of the following:
Escape the backslashes:-
-I"C:\\Users\\Dylan Galea\\workspace\\5\\source\\"
Replace them with forward slashes:
-I"C:/Users/Dylan Galea/workspace/5/source/"

luasocket.c:20:17: error: lua.h: No such file or directory

I'm installing luasocket module for Lua, but I got the following error message:
[root#localhost local]# wget http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2/luasocket-2.0.2.tar.gz
[root#localhost local]# tar zxvf luasocket-2.0.2.tar.gz
[root#localhost local]# cd luasocket-2.0.2
[root#localhost luasocket-2.0.2]# make && make install
cd src; make all
make[1]: Entering directory `/usr/local/luasocket-2.0.2/src'
gcc -DLUASOCKET_DEBUG -pedantic -Wall -O2 -fpic -c -o luasocket.o luasocket.c
luasocket.c:20:17: error: lua.h: No such file or directory
luasocket.c:21:21: error: lauxlib.h: No such file or directory
luasocket.c:24:24: error: compat-5.1.h: No such file or directory
In file included from luasocket.c:30:
luasocket.h:30: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:31:
auxiliar.h:37: error: expected ‘)’ before ‘*’ token
auxiliar.h:38: error: expected ‘)’ before ‘*’ token
auxiliar.h:39: error: expected ‘)’ before ‘*’ token
auxiliar.h:40: error: expected ‘)’ before ‘*’ token
auxiliar.h:41: error: expected ‘)’ before ‘*’ token
auxiliar.h:42: error: expected ‘)’ before ‘*’ token
auxiliar.h:43: error: expected ‘)’ before ‘*’ token
auxiliar.h:44: error: expected ‘)’ before ‘*’ token
auxiliar.h:45: error: expected ‘)’ before ‘*’ token
auxiliar.h:46: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:32:
except.h:33: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:33:
timeout.h:19: error: expected ‘)’ before ‘*’ token
timeout.h:26: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:34:
buffer.h:39: error: expected ‘)’ before ‘*’ token
buffer.h:41: error: expected ‘)’ before ‘*’ token
buffer.h:42: error: expected ‘)’ before ‘*’ token
buffer.h:43: error: expected ‘)’ before ‘*’ token
buffer.h:44: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:35:
inet.h:27: error: expected ‘)’ before ‘*’ token
inet.h:35: error: expected ‘)’ before ‘*’ token
inet.h:36: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:36:
tcp.h:34: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:37:
udp.h:31: error: expected ‘)’ before ‘*’ token
In file included from luasocket.c:38:
select.h:15: error: expected ‘)’ before ‘*’ token
luasocket.c:43: error: expected ‘)’ before ‘*’ token
luasocket.c:44: error: expected ‘)’ before ‘*’ token
luasocket.c:45: error: expected ‘)’ before ‘*’ token
luasocket.c:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mod’
luasocket.c:60: warning: ISO C does not allow extra ‘;’ outside of a function
luasocket.c:62: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘func’
luasocket.c:66: warning: ISO C does not allow extra ‘;’ outside of a function
luasocket.c:71: error: expected ‘)’ before ‘*’ token
luasocket.c:80: error: expected ‘)’ before ‘*’ token
luasocket.c:89: error: expected ‘)’ before ‘*’ token
luasocket.c:113: error: expected ‘)’ before ‘*’ token
make[1]: *** [luasocket.o] Error 1
make[1]: Leaving directory `/usr/local/luasocket-2.0.2/src'
make: *** [all] Error 2
Can anybody help me? thanks in advance :)
You will need to set LUAINC.
Since you didn't specify which OS you are using, I can't give you a
definitive answer what to set it to. On Debian, if you want to build
for Lua5.1, set it to -I/usr/include/lua5.1/
You can set the variable by editing config (which is included from
makefile) or by specifying it on the command line:
$ make LUAINC=-I/usr/include/lua5.1/
The recommended solution did not work for me using Alpine 3.4. In order to make it work in this environment I had to download the package and hack the following.
luasec-luasec-0.6/src/luasocket/usocket.h
/* TODO: ifdef the ALPINE #include <sys/poll.h> */
#include <poll.h>
Then changes to Makefile
# Inform the location to install the modules
LUAPATH ?= /usr/local/share/lua/5.1
LUACPATH ?= /usr/local/lib/lua/5.1
# Edit the lines below to inform new path, if necessary.
# Path below points to internal LuaSocket's help files.
LUAINCDIR = -I/usr/local/api-gateway/luajit/include/luajit-2.1
INC_PATH ?= -I/usr/include
LIB_PATH ?= -L/usr/lib
INCDIR = -I. $(LUAINCDIR) $(INC_PATH) <------ include new path
LIBDIR = -L./luasocket $(LIB_PATH)
Hope this helps if anyone else is stuck with this particular problem.

error: ‘CODEC_TYPE_AUDIO’ undeclared when make m3u8-segmenter

I want to make m3u8-segmenter for Http Live Stream: https://github.com/johnf/m3u8-segmenter
There are errors when I make, the errors are:
gcc -g -O -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast -Wwrite-strings -Werror m3u8-segmenter.c -o m3u8-segmenter -lavformat -lavcodec -lavutil
m3u8-segmenter.c: In function ‘add_output_stream’:
m3u8-segmenter.c:82:14: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
m3u8-segmenter.c:82:14: note: each undeclared identifier is reported only once for each function it appears in
m3u8-segmenter.c:94:14: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
m3u8-segmenter.c: In function ‘main’:
m3u8-segmenter.c:338:5: error: ‘av_open_input_file’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1090) [-Werror=deprecated-declarations]
m3u8-segmenter.c:352:5: error: implicit declaration of function ‘guess_format’ [-Werror=implicit-function-declaration]
m3u8-segmenter.c:352:5: error: nested extern declaration of ‘guess_format’ [-Werror=nested-externs]
m3u8-segmenter.c:352:10: error: assignment makes pointer from integer without a cast [-Werror]
m3u8-segmenter.c:371:18: error: ‘CODEC_TYPE_VIDEO’ undeclared (first use in this function)
m3u8-segmenter.c:376:18: error: ‘CODEC_TYPE_AUDIO’ undeclared (first use in this function)
m3u8-segmenter.c:387:5: error: ‘av_set_parameters’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1434) [-Werror=deprecated-declarations]
m3u8-segmenter.c:392:5: error: ‘dump_format’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1559) [-Werror=deprecated-declarations]
m3u8-segmenter.c:406:5: error: ‘url_fopen’ is deprecated (declared at /usr/local/include/libavformat/avio.h:279) [-Werror=deprecated-declarations]
m3u8-segmenter.c:411:5: error: ‘av_write_header’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1492) [-Werror=deprecated-declarations]
m3u8-segmenter.c:444:67: error: ‘PKT_FLAG_KEY’ undeclared (first use in this function)
m3u8-segmenter.c:455:13: error: ‘put_flush_packet’ is deprecated (declared at /usr/local/include/libavformat/avio.h:293) [-Werror=deprecated-declarations]
m3u8-segmenter.c:456:13: error: ‘url_fclose’ is deprecated (declared at /usr/local/include/libavformat/avio.h:280) [-Werror=deprecated-declarations]
m3u8-segmenter.c:476:13: error: ‘url_fopen’ is deprecated (declared at /usr/local/include/libavformat/avio.h:279) [-Werror=deprecated-declarations]
m3u8-segmenter.c:482:13: error: ‘av_write_header’ is deprecated (declared at /usr/local/include/libavformat/avformat.h:1492) [-Werror=deprecated-declarations]
m3u8-segmenter.c:514:5: error: ‘url_fclose’ is deprecated (declared at /usr/local/include/libavformat/avio.h:280) [-Werror=deprecated-declarations]
cc1: all warnings being treated as errors
make: *** [all] Error 1
You're getting those errors because for some reason, this block in libav_compat.h took effect:
/* Support older versions of ffmpeg and libav */
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 64, 0)
#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY
#endif
But whichever headers are supposed to define CODEC_TYPE_AUDIO and CODEC_TYPE_VIDEO don't. From the comment there, it looks like you probably should update your other software (ffmpeg and/or libav) and then try again.

Resources