Problem with msgget(......

Dear all,

I am new to QNX Nuetrino…
I am just trying to compile some progs using IPC
but when i am compiling the code which has msgget syscall
i got the following error

implicit declaration of function int msgget(...)' implicit declaration of function int msgsnd(…)’

I have included the msg.h file

anybody can help


your prototypes are not read before the function is used.

Prototype your functions AND structures on the beginning of the file helps.

Or the prototypes aren’t complete.

Thx for ur suggesion
but i have already written th eprototypes also
here is my code

using namespace std;

#include <sys/ipc.h>
#include <sys/stat.h>
#include <sys/types.h>

#define MSG_KEY (key_t)1097

extern int msgget(key_t __key, int __msgflg);

int main()
cout << “hello world” << endl;

key_t key = MSG_KEY ;
int msgflg = IPC_CREAT;

int queueid = msgget(key, msgflg);

if(queueid == -1){
	cout << "msg Q creation failed" << endl;
	cout << "msg Q creatd" << endl;




remove the extern keyword, you put extern if you want your function/variable to be read externally, not if you want to use a external defined function.

You say:

My function msgget(bla, blubb); should be able to be read by other sources.

You want:
My app wants to read the function called msgget(); from another source.

So you should be fine without the extern keyword and a later linking to the library the function is in

Perhaps you meant to type:

extern "C" {
  int msgget(key_t __key, int __msgflg);

… since you are apparently compiling C++ in this case; and you haven’t stated the linkage properties of the source file, but perhaps that is written in ‘C’ (a lot of stuff is written in C these days :slight_smile:

BTW - QNX doesn’t support SYSV IPC calls…

i have tried without extren also no use
i think as u people said

need to add nuetrino.h and apis related to that we have to use for IPC

But personally i feel that it should support posix statndrad SYSVs IPC Calls
as it is based on Unix

Thanks Guys

No, it’s not based on Unix. QNX is POSIX compliant, that doesn’t mean it’s Unix

Sry exactly what i mean is that
its a POSIX Complaint and should wrk POSIX standard APIs isn’t it?

There are many POSIX level. That being said I’m not sure if SYS VS IPC are POSIX at all. If they were, why would they be call SYS VS ;-)

Sys V IPC is not Posix…

Well of course he’s right. No one ever said that QNX does support Sys V IPC.