public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC 4.8.1 unable to compile a .c File
@ 2019-03-23 15:14 Vinaya Dandur
  2019-03-23 16:22 ` Jonathan Wakely
  0 siblings, 1 reply; 9+ messages in thread
From: Vinaya Dandur @ 2019-03-23 15:14 UTC (permalink / raw)
  To: gcc

Dear Developers,

It is unfortunate that I am facing this issue and to my bad luck, I do not
see an answer on google as well.

Problem:

I have downloaded and compiled GCC 4.8.1 with the below configure options
on SLES 12 and post installation, created soft links cc c++ gcc and g++ to
point to gcc-4.8.1 and g++-4.8.1 .

./configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man
--libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-checking=release
--enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
--with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
--with-slibdir=/lib64 --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.8.1
--enable-linux-futex --without-system-libunwind --with-cpu=generic
--build=x86_64-suse-linux --disable-multilib --enable-languages=c,c++

A simple .c program would copilte which has a simple print with the new
compiler, but not the below one.

Program:
++++++++++
#include <stdio.h>
#include <sys/resource.h>

int main () {

printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);

return 0;
}
+++++++

ecomdev:/tmp # cc test.c
test.c: In function ‘main’:
test.c:6:31: error: ‘TRAP_BRKPT’ undeclared (first use in this function)
 printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
                               ^
test.c:6:31: note: each undeclared identifier is reported only once for
each function it appears in
ecomdev:/tmp #

The cc include path is,
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/gcc/x86_64-suse-linux/4.8/include/
 /usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed
 /usr/lib64/gcc/x86_64-suse-linux/4.8.1/include
 /usr/lib64/gcc/x86_64-suse-linux/4.8.1/include-fixed
 /usr/local/include
 /usr/local/private-gcc/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
ecomdev:/tmp #


Could you please guide as to what went wrong and help me out with the
compilation. I am super frustrated, having this issue around

Thanks and Regards,
Vinaya D R

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 15:14 GCC 4.8.1 unable to compile a .c File Vinaya Dandur
@ 2019-03-23 16:22 ` Jonathan Wakely
  2019-03-23 16:25   ` Vinaya Dandur
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2019-03-23 16:22 UTC (permalink / raw)
  To: Vinaya Dandur; +Cc: gcc

On Sat, 23 Mar 2019 at 15:15, Vinaya Dandur <mail2vinaya@gmail.com> wrote:
>
> Dear Developers,
>
> It is unfortunate that I am facing this issue and to my bad luck, I do not
> see an answer on google as well.
>
> Problem:
>
> I have downloaded and compiled GCC 4.8.1 with the below configure options
> on SLES 12 and post installation, created soft links cc c++ gcc and g++ to
> point to gcc-4.8.1 and g++-4.8.1 .
>
> ./configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man
> --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-checking=release
> --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
> --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
> --with-slibdir=/lib64 --enable-__cxa_atexit
> --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
> --enable-version-specific-runtime-libs --program-suffix=-4.8.1
> --enable-linux-futex --without-system-libunwind --with-cpu=generic
> --build=x86_64-suse-linux --disable-multilib --enable-languages=c,c++
>
> A simple .c program would copilte which has a simple print with the new
> compiler, but not the below one.
>
> Program:
> ++++++++++
> #include <stdio.h>
> #include <sys/resource.h>
>
> int main () {
>
> printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
>
> return 0;
> }
> +++++++
>
> ecomdev:/tmp # cc test.c
> test.c: In function ‘main’:
> test.c:6:31: error: ‘TRAP_BRKPT’ undeclared (first use in this function)
>  printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
>                                ^
> test.c:6:31: note: each undeclared identifier is reported only once for
> each function it appears in
> ecomdev:/tmp #

This is not a problem with GCC, it just means the TRAP_BRKPT symbol
isn't defined in the headers you've included.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 16:22 ` Jonathan Wakely
@ 2019-03-23 16:25   ` Vinaya Dandur
  2019-03-23 16:46     ` Paul Smith
  2019-03-23 17:08     ` Jonathan Wakely
  0 siblings, 2 replies; 9+ messages in thread
From: Vinaya Dandur @ 2019-03-23 16:25 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc

Hi Jonathan,

Thank you. Yes it is not an issue with the GCC but the TRAP_BRKPT is
defined in signal.h which the GCC could include but can't find the constant
mentioned.
Is there any way this problem could be resolved ? any pointers I can get ?

Thanks and Regards,
Vinaya D R


On Sat, Mar 23, 2019 at 9:52 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:

> On Sat, 23 Mar 2019 at 15:15, Vinaya Dandur <mail2vinaya@gmail.com> wrote:
> >
> > Dear Developers,
> >
> > It is unfortunate that I am facing this issue and to my bad luck, I do
> not
> > see an answer on google as well.
> >
> > Problem:
> >
> > I have downloaded and compiled GCC 4.8.1 with the below configure options
> > on SLES 12 and post installation, created soft links cc c++ gcc and g++
> to
> > point to gcc-4.8.1 and g++-4.8.1 .
> >
> > ./configure --prefix=/usr --infodir=/usr/share/info
> --mandir=/usr/share/man
> > --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-checking=release
> > --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
> > --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
> > --with-slibdir=/lib64 --enable-__cxa_atexit
> > --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
> > --enable-version-specific-runtime-libs --program-suffix=-4.8.1
> > --enable-linux-futex --without-system-libunwind --with-cpu=generic
> > --build=x86_64-suse-linux --disable-multilib --enable-languages=c,c++
> >
> > A simple .c program would copilte which has a simple print with the new
> > compiler, but not the below one.
> >
> > Program:
> > ++++++++++
> > #include <stdio.h>
> > #include <sys/resource.h>
> >
> > int main () {
> >
> > printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
> >
> > return 0;
> > }
> > +++++++
> >
> > ecomdev:/tmp # cc test.c
> > test.c: In function ‘main’:
> > test.c:6:31: error: ‘TRAP_BRKPT’ undeclared (first use in this function)
> >  printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
> >                                ^
> > test.c:6:31: note: each undeclared identifier is reported only once for
> > each function it appears in
> > ecomdev:/tmp #
>
> This is not a problem with GCC, it just means the TRAP_BRKPT symbol
> isn't defined in the headers you've included.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 16:25   ` Vinaya Dandur
@ 2019-03-23 16:46     ` Paul Smith
  2019-03-23 17:08     ` Jonathan Wakely
  1 sibling, 0 replies; 9+ messages in thread
From: Paul Smith @ 2019-03-23 16:46 UTC (permalink / raw)
  To: Vinaya Dandur; +Cc: gcc

On Sat, 2019-03-23 at 21:55 +0530, Vinaya Dandur wrote:
> Thank you. Yes it is not an issue with the GCC but the TRAP_BRKPT is
> defined in signal.h which the GCC could include but can't find the
> constant mentioned.
> Is there any way this problem could be resolved ? any pointers I can
> get ?

If the macro is defined in signal.h then you should #include signal.h. 
Is there some issue here we're not seeing?

> > > Program:
> > > ++++++++++
> > > #include <stdio.h>
> > > #include <sys/resource.h>
> > > 
> > > int main () {
> > > 
> > > printf("TRAP_BRKPT is: %d\n", TRAP_BRKPT);
> > > 
> > > return 0;
> > > }
> > > +++++++

Questions about how to write correct C are definitely not on-topic for
this mailing list.  Maybe try posting a question on StackOverflow?

Cheers!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 16:25   ` Vinaya Dandur
  2019-03-23 16:46     ` Paul Smith
@ 2019-03-23 17:08     ` Jonathan Wakely
  2019-03-23 17:25       ` Vinaya Dandur
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2019-03-23 17:08 UTC (permalink / raw)
  To: Vinaya Dandur; +Cc: gcc

On Sat, 23 Mar 2019 at 16:25, Vinaya Dandur <mail2vinaya@gmail.com> wrote:
>
> Hi Jonathan,
>
> Thank you. Yes it is not an issue with the GCC but the TRAP_BRKPT is defined in signal.h which the GCC could include but can't find the constant mentioned.

Your code doesn't include <signal.h>, how do you expect it to find
anything defined in <signal.h> if you don't include it?

There is no TRAP_BRKPT on GNU/Linux, maybe you're trying to compile
Android code, and should use the Android SDK?

> Is there any way this problem could be resolved ? any pointers I can get ?

This is not a GCC problem, so you should find a more appropriate place to ask.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 17:08     ` Jonathan Wakely
@ 2019-03-23 17:25       ` Vinaya Dandur
  2019-03-23 18:24         ` Paul Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Vinaya Dandur @ 2019-03-23 17:25 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc

My mistake. Thanks, but even if you include <signal.h> the issue still
exists. Yes TRAP_BRKPT is not included in signal.h, however gcc somehow
finds the definition for TRAP_BRKPT and I don't know how. This works in
other hosts. Any how I shall post the question on other platforms. Thanks
for you time.

Thanks and Regards,
Vinaya D R


On Sat, Mar 23, 2019 at 10:38 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:

> On Sat, 23 Mar 2019 at 16:25, Vinaya Dandur <mail2vinaya@gmail.com> wrote:
> >
> > Hi Jonathan,
> >
> > Thank you. Yes it is not an issue with the GCC but the TRAP_BRKPT is
> defined in signal.h which the GCC could include but can't find the constant
> mentioned.
>
> Your code doesn't include <signal.h>, how do you expect it to find
> anything defined in <signal.h> if you don't include it?
>
> There is no TRAP_BRKPT on GNU/Linux, maybe you're trying to compile
> Android code, and should use the Android SDK?
>
> > Is there any way this problem could be resolved ? any pointers I can get
> ?
>
> This is not a GCC problem, so you should find a more appropriate place to
> ask.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 17:25       ` Vinaya Dandur
@ 2019-03-23 18:24         ` Paul Smith
  2019-03-24  0:50           ` Vinaya Dandur
  2019-03-26 13:07           ` Vinaya Dandur
  0 siblings, 2 replies; 9+ messages in thread
From: Paul Smith @ 2019-03-23 18:24 UTC (permalink / raw)
  To: Vinaya Dandur; +Cc: gcc

On Sat, 2019-03-23 at 22:54 +0530, Vinaya Dandur wrote:
> My mistake. Thanks, but even if you include <signal.h> the issue still
> exists. Yes TRAP_BRKPT is not included in signal.h, however gcc somehow
> finds the definition for TRAP_BRKPT and I don't know how. This works in
> other hosts.

A peruse of the sigaction man page for GNU/Linux might be enlightening:

http://man7.org/linux/man-pages/man2/sigaction.2.html

> Since glibc 2.20, the definitions of most of these symbols are
> obtained from <signal.h> by defining feature test macros (before
> including any header file) as follows:
> 
>   *  _XOPEN_SOURCE with the value 500 or greater;
>   *  _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED; or
>   *  _POSIX_C_SOURCE with the value 200809L or greater.
> 
> For the TRAP_* constants, the symbol definitions are provided only
> in the first two cases.  Before glibc 2.20, no feature test macros
> were required to obtain these symbols.

So if you add #define _XOPEN_SOURCE 500 or both #define _XOPEN_SOURCE
and #define _XOPEN_SOURCE_EXTENDED before your first #include, or if
you add -D_XOPEN_SOURCE=500 or both -D_XOPEN_SOURCE and
-D_XOPEN_SOURCE_EXTENDED to your compile line, then things should work.

This is a question related to the GNU libc project, not GCC.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 18:24         ` Paul Smith
@ 2019-03-24  0:50           ` Vinaya Dandur
  2019-03-26 13:07           ` Vinaya Dandur
  1 sibling, 0 replies; 9+ messages in thread
From: Vinaya Dandur @ 2019-03-24  0:50 UTC (permalink / raw)
  To: psmith; +Cc: gcc

Don't know how to thank you. Thanks a ton. Will try this out.

I am happy that the gcc developer community listens.

On Sat, 23 Mar, 2019, 11:53 PM Paul Smith, <psmith@gnu.org> wrote:

> On Sat, 2019-03-23 at 22:54 +0530, Vinaya Dandur wrote:
> > My mistake. Thanks, but even if you include <signal.h> the issue still
> > exists. Yes TRAP_BRKPT is not included in signal.h, however gcc somehow
> > finds the definition for TRAP_BRKPT and I don't know how. This works in
> > other hosts.
>
> A peruse of the sigaction man page for GNU/Linux might be enlightening:
>
> http://man7.org/linux/man-pages/man2/sigaction.2.html
>
> > Since glibc 2.20, the definitions of most of these symbols are
> > obtained from <signal.h> by defining feature test macros (before
> > including any header file) as follows:
> >
> >   *  _XOPEN_SOURCE with the value 500 or greater;
> >   *  _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED; or
> >   *  _POSIX_C_SOURCE with the value 200809L or greater.
> >
> > For the TRAP_* constants, the symbol definitions are provided only
> > in the first two cases.  Before glibc 2.20, no feature test macros
> > were required to obtain these symbols.
>
> So if you add #define _XOPEN_SOURCE 500 or both #define _XOPEN_SOURCE
> and #define _XOPEN_SOURCE_EXTENDED before your first #include, or if
> you add -D_XOPEN_SOURCE=500 or both -D_XOPEN_SOURCE and
> -D_XOPEN_SOURCE_EXTENDED to your compile line, then things should work.
>
> This is a question related to the GNU libc project, not GCC.
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: GCC 4.8.1 unable to compile a .c File
  2019-03-23 18:24         ` Paul Smith
  2019-03-24  0:50           ` Vinaya Dandur
@ 2019-03-26 13:07           ` Vinaya Dandur
  1 sibling, 0 replies; 9+ messages in thread
From: Vinaya Dandur @ 2019-03-26 13:07 UTC (permalink / raw)
  To: psmith; +Cc: gcc

The suggestion worked like magic. Thanks.

Thanks and Regards,
Vinaya D R


On Sat, Mar 23, 2019 at 11:53 PM Paul Smith <psmith@gnu.org> wrote:

> On Sat, 2019-03-23 at 22:54 +0530, Vinaya Dandur wrote:
> > My mistake. Thanks, but even if you include <signal.h> the issue still
> > exists. Yes TRAP_BRKPT is not included in signal.h, however gcc somehow
> > finds the definition for TRAP_BRKPT and I don't know how. This works in
> > other hosts.
>
> A peruse of the sigaction man page for GNU/Linux might be enlightening:
>
> http://man7.org/linux/man-pages/man2/sigaction.2.html
>
> > Since glibc 2.20, the definitions of most of these symbols are
> > obtained from <signal.h> by defining feature test macros (before
> > including any header file) as follows:
> >
> >   *  _XOPEN_SOURCE with the value 500 or greater;
> >   *  _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED; or
> >   *  _POSIX_C_SOURCE with the value 200809L or greater.
> >
> > For the TRAP_* constants, the symbol definitions are provided only
> > in the first two cases.  Before glibc 2.20, no feature test macros
> > were required to obtain these symbols.
>
> So if you add #define _XOPEN_SOURCE 500 or both #define _XOPEN_SOURCE
> and #define _XOPEN_SOURCE_EXTENDED before your first #include, or if
> you add -D_XOPEN_SOURCE=500 or both -D_XOPEN_SOURCE and
> -D_XOPEN_SOURCE_EXTENDED to your compile line, then things should work.
>
> This is a question related to the GNU libc project, not GCC.
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-03-26 13:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23 15:14 GCC 4.8.1 unable to compile a .c File Vinaya Dandur
2019-03-23 16:22 ` Jonathan Wakely
2019-03-23 16:25   ` Vinaya Dandur
2019-03-23 16:46     ` Paul Smith
2019-03-23 17:08     ` Jonathan Wakely
2019-03-23 17:25       ` Vinaya Dandur
2019-03-23 18:24         ` Paul Smith
2019-03-24  0:50           ` Vinaya Dandur
2019-03-26 13:07           ` Vinaya Dandur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).