getpgid() won't work in g++!

getpgid() won't work in g++!

Post by Lars Hagstro » Tue, 29 Feb 2000 04:00:00



Hi,

I've come across something that I find very odd and I haven't been able to
find any previous questions about it anywhere. I hope it's not a silly question
with an obvious answer.

I've narrowed the problem down to a very simple one.
If I compile the following program with gcc (as a C program) it works
fine.

#include<unistd.h>
int main()
{
  return getpgid(0);

Quote:}

But when I compile it with g++ as a C++ program I get this message:
test.cc: In function `int main()':
test.cc:6: implicit declaration of function `int getpgid(...)'

If I do a forward declaration of the getpgid fcn I will get a link error:
/tmp/ccHofd4c.o: In function `main':
/tmp/ccHofd4c.o(.text+0xc): undefined reference to `getpgid(int)'
collect2: ld returned 1 exit status

At least this is the behaviour on Linux distros mandrake 6.1 and 7.0
and debian potato (i think). This is with version 2.95.2.
On a VAX (Ultrix 4.4) with 2.8.1 I get both link error and warning in
c++ and only the link error in c.

On a Sun UltraSparc with SunOS 5.7 (Solaris v??) and gcc 2.95.1 everything
works just fine.

Is this a real bug or am I missing something?

Thanks in advance
        Lars

--

 
 
 

getpgid() won't work in g++!

Post by Thomas Rehlic » Tue, 29 Feb 2000 04:00:00



> Hi,

> I've come across something that I find very odd and I haven't been able to
> find any previous questions about it anywhere. I hope it's not a silly question
> with an obvious answer.

> I've narrowed the problem down to a very simple one.
> If I compile the following program with gcc (as a C program) it works
> fine.

> #include<unistd.h>
> int main()
> {
>   return getpgid(0);
> }

> But when I compile it with g++ as a C++ program I get this message:
> test.cc: In function `int main()':
> test.cc:6: implicit declaration of function `int getpgid(...)'

It seems that GNU-C/C++ is a little bit to perfect. The prototype of getpgid in
unistd.h is enclosed in
#ifdef __USE_XOPEN_EXTENDED ... #endif since this function is a X/Open Unix
extension (?).
Try to compile with -D_XOPEN_SOURCE=500 or -D_GNU_SOURCE and it works.

Thomas

 
 
 

1. how do 'plug-ins' work?

I've got a little project I'm working on that could benifit from being able to
drop in third-party extensions as plug-ins.  I understand the plug-in theory,
more or less, but I'm fuzzy on the implementation details.  I was hoping someone
could help me out a bit.

As I understand it (and please correct me if I'm wrong), if I create a function
library and compile it as a static object then I have to compile the final app
along with that object.  If I make my library a shared object than I just have to
link against it at compile time and it's included at run-time (I've never made
any of my own so's - do you have to do anything different than what you'd do for
a static object?).

But what if I want to create a library that I can just drop into an app without
having to recompile against it (such as a netscape-style plug-in)?  Obviously
there has to be some agreed-upon api so the app knows what entry points exist in
the library and the library knows what functions the app exposes, but how does
the app actually 'load' the library while it's running?

I noticed some functions for loading dynamic modules in a glib reference and this
seems like it would be a place to start, but once I've loaded the module is there
anything special I have to do to call it's functions or do they just magically
become available?  This is the part where I'm getting lost...

If anyone can point me to a good online resource for this or drop me a basic
explanation, I'd be grateful.  I've looked over netscape's plug-in docs but that
mostly concentrates on the api side of things.  I spent some time digging through
the gimp source but gimp plug-ins appear to run as a separate process which isn't
really the behavior I'm after (I could probably still do what I want that way,
but I need to get a handle on this whole library thing anyway ;).

thanks in advance,

e
--
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|  Ethan VonderWeid                          IT Technical Operations  |

|  (650) 336-0534 (internal x60534)              This space for rent  |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+

2. RPM Hell is no more?!

3. CD won't work, system won't reboot...please help

4. Setting up a Terminal

5. help needed: AWE32 PNP won't work - kernel won't compile - gurus read this!

6. Problems mounting filesystems from WinNT/95/98 Machines

7. After linux's network works, win XP's network cannot work ?

8. anyway to rebuild /var/sadm/install/contents ?

9. IP Accounting doesn't work for PPP dial-ins :-(( ??

10. What's 'side effects' of Ksh built-ins?

11. 'make' won't work w/o '-f Makefile', which sucks.

12. why won't scripts work unless i 'source' them?

13. The command 'rcp' won't work???