share memory and memory map problem

I got a problem upgrading shared memory from QNX4.0 to Neutrino and this is the problem:

int mem;
unsigned char *where

where=mmap(o, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, mem, 0)

mem=shm_open(“mem_test”, O_CREAT|O_RDWR, 0777)

if(where!=(void*0-1)
{
strcpy(where, “original string”);

}

The complier complains about the strcpy. Why is that? thanks.

Try to change the order of your function calls. First shm_open, then use ftruncate(when you are creating the shared mem). After that use the mmap function.
Good luck
Frank 8)

Hi

Apart from mistake in your code (which Frank pointed out), you can fix the compiler error by-

  1. Quick-method
    a) Use qcc !
    b) Use “-fno-builtin -fhonor-std” options with gcc/g++
    c) Prefix “std::” with all functions you get error like “std::strcpy”

  2. Read the “namespaces” chapter from Stroupstrop (sorry spelling mistake probably) or Bruce Eckle’s Thinking in C++ (available online or free from eckleobjects.com)

HTH
_ Akhilesh Mritunjai

Next time, try the programming groups for programming questions.
/Johan