By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,983 Members | 1,582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,983 IT Pros & Developers. It's quick & easy.

compiling a simple program

P: n/a
Hi there ...

I need to know how to compile the program idba1EnableSignal.c to get
idba1EnableSignal.o.
I tried like below but I got some errors. I believe it is because it
cannot find signal.h but I just don't know how to include this when
compiling. I am not a c-programmer.

$ gcc -c idba1EnableSignal.c -ansi
idba1EnableSignal.c: In function `idba1EnableSignal':
idba1EnableSignal.c:25: error: `SIGHUP' undeclared (first use in this
function)
idba1EnableSignal.c:25: error: (Each undeclared identifier is reported
only once
idba1EnableSignal.c:25: error: for each function it appears in.)
idba1EnableSignal.c:26: error: `SIGQUIT' undeclared (first use in this
function)
idba1EnableSignal.c:27: error: `SIGKILL' undeclared (first use in this
function)

idba1EnableSignal.c
------------------------
#include <sys/signal.h>

extern void CleanUp();

void idba1EnableSignal()
{
signal(SIGINT, CleanUp);
signal(SIGHUP, CleanUp);
signal(SIGQUIT, CleanUp);
signal(SIGKILL, CleanUp);

return;
}

Thanks.
Daud

Nov 14 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
sys/signal.h file is in /usr/include/sys/include

By defaukt compiler looks into /usr/include.

Try giving the path of sys/signal.h using -I option in gcc

Nov 14 '05 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"khurana77" <rk******@gmail.com> writes:
sys/signal.h file is in /usr/include/sys/include

By defaukt compiler looks into /usr/include.

Try giving the path of sys/signal.h using -I option in gcc


This is offtopic, but also incorrect. The correct include is
<signal.h> (see SUSv3).
- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCnFEEVcFcaSW/uEgRAsAqAKCQOJtK+ftnBofU91u/jKbvdbTGxwCg5I6G
2YV/KZOBKipoiumKo+2pnT4=
=5XiC
-----END PGP SIGNATURE-----
Nov 14 '05 #3

P: n/a
Daud wrote:
.... snip ... #include <sys/signal.h>
No such thing in standard C - use <signal.h>

extern void CleanUp();

void idba1EnableSignal()
{
signal(SIGINT, CleanUp);
signal(SIGHUP, CleanUp);
signal(SIGQUIT, CleanUp);
signal(SIGKILL, CleanUp);

return;
}
Only <signal.h> is defined. You seem to be using some system
dependant things, so try a newsgroup that deals with your system.From N869.


[#3] The macros defined are

SIG_DFL
SIG_ERR
SIG_IGN

which expand to constant expressions with distinct values
that have type compatible with the second argument to, and
the return value of, the signal function, and whose values
compare unequal to the address of any declarable function;
and the following, which expand to positive integer constant
expressions with type int and distinct values that are the
signal numbers, each corresponding to the specified
condition:

SIGABRT abnormal termination, such as is initiated
by the abort function

SIGFPE an erroneous arithmetic operation, such as
zero divide or an operation resulting in
overflow

SIGILL detection of an invalid function image, such
as an invalid instruction

SIGINT receipt of an interactive attention signal

SIGSEGV an invalid access to storage

SIGTERM a termination request sent to the program

[#4] An implementation need not generate any of these
signals, except as a result of explicit calls to the raise
function. Additional signals and pointers to undeclarable
functions, with macro definitions beginning, respectively,
with the letters SIG and an uppercase letter or with SIG_
and an uppercase letter,197) may also be specified by the
implementation. The complete set of signals, their
semantics, and their default handling is implementation-
defined; all signal numbers shall be positive.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #4

P: n/a
Its One and the same thing in Linux sys/signal.h includes the file
signal.h as
#include <signal.h>

Nov 14 '05 #5

P: n/a

"khurana77" <rk******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Its One and the same thing in Linux sys/signal.h includes the file
signal.h as
#include <signal.h>


On FreeBSD signal.h includes sys/signal.h (not vice versa)
I'd take another look at your headers - according to the standard
the macros are supposed to be defined after the inclusion of signal.h
(note - the standard doesn't refer to sys/signal.h anywhere!)
That being said, the correct include is <signal.h> and NOT sys/signal.h

Nov 14 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.