Refresh . My teacher accepts code written in the GNU99 standard, so as user1 pointed out, I used it _GNU_SOURCEat the beginning of my program. (See man feature_test_macrosfor more information.) Thanks for helping me understand!
On Ubuntu 13.10 with Clang 3.4, GCC 4.8.1, I am doing a task that requires me to use the C99 standard. (I also have GNUstep installed from SVN)
WRT GCC, I think I have 4 versions installed in these folders:
/usr/lib/gcc/x86_64-linux-gnu/4.7
/usr/lib/gcc/x86_64-linux-gnu/4.7.3
/usr/lib/gcc/x86_64-linux-gnu/4.8
/usr/lib/gcc/x86_64-linux-gnu/4.8.1
gcc --versionreports reports 4.8.1, clang --version3.4. ld -vreports 2.23.52.20130913
I write a signal handler, and when I use siginfo_t in the function header, I get a compiler error: unknown type name 'siginfo_t'I use sigaction () to set the handler.
By learning what to do and how, I was able to compile a simple demo that also uses the same function header definition, and it works. However, this is not limited to C99.
These are my included ones (of which signal.h is one):
#define _POSIX_C_SOURCE 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <math.h>
#include <ctype.h>
#include <libgen.h>
#include <signal.h>
This is my signal handler function (for debugging purposes only):
static void sigSIGCHLDhandler(int sigNum, siginfo_t *siginfo, void *context) {
printf("PID = %ld",(long) siginfo->si_pid);
}
I compile with clangusing -Walland are now options. -std=c99-std=gnu99
I tried locate signal.h, and I have it in /usr/include. I tried to add #include <bits/siginfo.h>, and this allowed me to compile, but the binary will not work correctly.
(My system has a bunch of files signal.hand siginfo.h.)
, - . Clang. , , , (, , - )
LD_LIBRARY_PATH=/home/user/ros_catkin_ws/install_isolated/lib:/home/user/GNUstep/Library/Libraries:/usr/local/lib
CPATH=/home/user/ros_catkin_ws/install_isolated/include
PATH=/home/user/ros_catkin_ws/install_isolated/bin:/home/user/GNUstep/Tools:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/user/bin:/usr/local/java/jdk1.7.0_51/bin
CLASSPATH=/home/user/GNUstep/Library/Libraries/Java:/usr/local/lib/GNUstep/Libraries/Java
LIBRARY_COMBO=gnu-gnu-gnu
INFOPATH=/usr/local/share/info::/home/user/GNUstep/Library/Documentation/info:
GNUSTEP_IS_FLATTENED=yes
GNUSTEP_LOCAL_ROOT=/usr/local/Local
GNUSTEP_HOST=x86_64-unknown-linux-gnu
GUILE_LOAD_PATH=/home/user/GNUstep/Library/Libraries/Guile:/usr/local/lib/GNUstep/Libraries/Guile
GNUSTEP_MAKEFILES=/usr/local/share/GNUstep/Makefiles
GNUSTEP_NETWORK_ROOT=/usr/local/Network
GNUSTEP_FLATTENED=yes
GNUSTEP_HOST_OS=linux-gnu
GNUSTEP_HOST_VENDOR=unknown
GNUSTEP_HOST_CPU=x86_64
GNUSTEP_USER_ROOT=/home/user/GNUstep
GNUSTEP_SYSTEM_ROOT=/usr/local/System
GNUSTEP_PATHLIST=/usr/local/System:/usr/local/Network:/usr/local/Local:/home/user/GNUstep
GNUSTEP_SYSTEM_ROOT=/usr/local/System
GNUSTEP_PATHLIST=/usr/local/System:/usr/local/Network:/usr/local/Local:/home/nap/GNUstep
, , .
?