I want to compile some C++ software that one can download here. It’s from 2001. Running make should do the trick.
I’m on Ubuntu 10.10 and I had to change gcc in the makefile to g++ for compilation to work.
Warnings:
Now, the program needs to scan a parameter file. When I compile, I receive several warnings:
g++ -c -o packet_data_agent.o packet_data_agent.cpp
packet_data_agent.cpp: In constructor ‘PACKET_DATA_AGENT::PACKET_DATA_AGENT()’:
packet_data_agent.cpp:34: warning: deprecated conversion from string constant to ‘char*’
packet_data_agent.cpp: In member function ‘void PACKET_DATA_AGENT::initialize(FILE*, FILE*)’:
packet_data_agent.cpp:109: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp:128: warning: format ‘%d’ expects type ‘int*’, but argument 3 has type ‘int32*’
packet_data_agent.cpp:131: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp:136: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp:141: warning: format ‘%d’ expects type ‘int*’, but argument 3 has type ‘int32*’
packet_data_agent.cpp:144: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp:149: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp: In member function ‘int32 PACKET_DATA_AGENT::get_PDU(int32, VIRTUAL_PDU*)’:
packet_data_agent.cpp:213: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp:244: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp: In member function ‘void PACKET_DATA_AGENT::put_PDU(int32, VIRTUAL_PDU*)’:
packet_data_agent.cpp:312: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘int32’
packet_data_agent.cpp: In member function ‘void PACKET_DATA_AGENT::write_statistics(FILE*)’:
packet_data_agent.cpp:393: warning: format ‘%10d’ expects type ‘int’, but argument 3 has type ‘int32’
packet_data_agent.cpp:394: warning: format ‘%10d’ expects type ‘int’, but argument 3 has type ‘int32’
g++ -O4 mobile_ip.o loss_generator.o radio_link_agent.o packet_data_agent.o -o mobile_ip -lm
My Problem:
Those lead to the fact that I can’t parse the included settings file. In the packet_data_agent.h, the variable is declared as int32:
int32 compressed_Internet_header_size;
And the C++ code to scan the parameter file in packet_data_agent.cpp:128:
fscanf(ParameterFile_ptr,"- compressed RTP/UDP/IP header size (in bytes): %d\n",&compressed_Internet_header_size);
But when I run the program, I receive the following error:
!!error in module PACKET-DATA-AGENT: illegal value 0 for the compressed RTP/UDP/IP header size
Although the parameter file clearly has:
- compressed RTP/UDP/IP header size (in bytes): 3
What can I do to make the program correctly parse the parameter file?
Additional information:
- Size of
inton my platform is 4
Here’s my g++ version:
$ g++ -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
Some very simple debugging:
I changed the source code as follows:
int return_test = fscanf(ParameterFile_ptr,"- compressed RTP/UDP/IP header size (in bytes): %d\n",&compressed_Internet_header_size);
printf ("%d\n", return_test);
printf ("%d\n", compressed_Internet_header_size);
The output is 0, 0. What could that mean? I mean, seriously, it’s right in front of me and it won’t find the parameter?
The warnings:
The header
global.hmakesint32a synonym forlong. gcc is issuing warnings when you pass alonginto*printfwith format code%dbecause on some platforms (any where anintis 32 bits and alongis 64, or where anintis 16 bits and alongis 32) that will have very bad results.You could just change the typedef so that
int32meansintrather thanlongand probably nothing bad will happen.The actual error when run:
[EDITED in the light of new information from original question-asker:]
It doesn’t seem that this has anything to do with the
int/long/int32stuff: rather,fscanfis failing to read that line of the parameter file. What about earlier lines? Isfscanfreturning 1 for them all, or is it actually going wrong earlier in a way that doesn’t make it stop trying to parse the file?Assuming that all the earlier
fscanfcalls are succeeding and this is the first failing one: What happens if you copy-and-paste the fixed boilerplate stuff from the source code into the file? What if you make it just look for a number without any of the fixed boilerplate text? There aren’t any other lines in your parameter file between thefile containing the output RTP streamline and thecompressed RTP/UDP/IP header sizeline, are there?You may be able to get some idea of where it’s failing as follows: After the offending
fscanfcall, read a bit of the parameter file usingfread, display it, and exit (no point trying to continue, of course; the parser will be completely confused if you do). If, e.g., it’s failed because it ran across a character that didn’t match the constant text in thefscanfformat string, this should give you the non-matching character and some of what follows. If it’s failed because it tried to read an integer and saw something it didn’t like, then you should get the first character it couldn’t interpret as part of an integer and some of what follows. Etc.