From mboxrd@z Thu Jan 1 00:00:00 1970 From: tex_tarro@hotmail.com To: help-gcc@gnu.org Subject: Compilation flags with GCC 2.8.1 Date: Tue, 05 Oct 1999 02:44:00 -0000 Message-id: <7tcgj1$jjl$1@nnrp1.deja.com> X-SW-Source: 1999-10/msg00066.html We developed one application using HP-UX 10.20 proprietary C compiler. Now we are trying compile it using GCC 2.8.1 and we found a problem with compilation flags. HP compiler has +u1 flag we didn't find in GCC compiler. This option is vital for our code. In fact, skipping it cause the core dump of our application. If you would like, try the following example: 1) Use the following file mappa.c #include #include #include #include #define file "systabina.txt" main() { void *p_map=NULL; off_t fsize, pagesize; int boot_fd = -1, i; void *temp = NULL; char *temp_c = NULL; short *temp_i = NULL; if ((boot_fd=open(file, O_RDWR)) < 0) printf("Error in file openening\n"); fsize = lseek(boot_fd, 0, SEEK_END); if(fsize <0) printf("ERRORE fsize <0\n"); pagesize = sysconf(_SC_PAGE_SIZE); p_map = (void *) mmap (NULL, fsize, (PROT_READ|PROT_WRITE), (MAP_FILE|MAP_VARIABLE|MAP_SHARED), boot_fd,0); if ( p_map == (void *)-1) printf("Error in file mapping\n"); temp_c = ((char *)p_map) + 1; printf("char num. 2 = %c\n", *temp_c); temp_i = (short *) ((char *) p_map+1); printf("short = %hd\n", *temp_i); } This code accesses a txt file, called systabina.txt, one line long that is: Questo file ha lo scopo di determinare eventuali problemi di memory fault 2) Compile it using HP compiler in this way: %> cc +u1 -o mappa mappa.c 3) Run mappa and obtain the following result: %> mappa char num. 2 = u short = 30053 4) Now compile it without +u1 flag and run it %> cc -o mappa mappa.c %> mappa char num. 2 = u (Bus error core dumped) 5) If you try with gcc you obtain the same result: %> gcc -o mappa mappa.c %> mappa char num. 2 = u (Bus error core dumped) We would like to find the correspondent flag +u1 for gcc or adding a define in the code as workaround. We cannot strongly modify the code. I mean each structure or similar. Can someone help us? Thank you Sent via Deja.com http://www.deja.com/ Before you buy. From mboxrd@z Thu Jan 1 00:00:00 1970 From: tex_tarro@hotmail.com To: help-gcc@gnu.org Subject: Compilation flags with GCC 2.8.1 Date: Sun, 31 Oct 1999 13:57:00 -0000 Message-ID: <7tcgj1$jjl$1@nnrp1.deja.com> X-SW-Source: 1999-10n/msg00066.html Message-ID: <19991031135700.YekMl8Y0Kk_BWDgaS4N8bXSemV7DyGbN7l8fbqcnlJI@z> We developed one application using HP-UX 10.20 proprietary C compiler. Now we are trying compile it using GCC 2.8.1 and we found a problem with compilation flags. HP compiler has +u1 flag we didn't find in GCC compiler. This option is vital for our code. In fact, skipping it cause the core dump of our application. If you would like, try the following example: 1) Use the following file mappa.c #include #include #include #include #define file "systabina.txt" main() { void *p_map=NULL; off_t fsize, pagesize; int boot_fd = -1, i; void *temp = NULL; char *temp_c = NULL; short *temp_i = NULL; if ((boot_fd=open(file, O_RDWR)) < 0) printf("Error in file openening\n"); fsize = lseek(boot_fd, 0, SEEK_END); if(fsize <0) printf("ERRORE fsize <0\n"); pagesize = sysconf(_SC_PAGE_SIZE); p_map = (void *) mmap (NULL, fsize, (PROT_READ|PROT_WRITE), (MAP_FILE|MAP_VARIABLE|MAP_SHARED), boot_fd,0); if ( p_map == (void *)-1) printf("Error in file mapping\n"); temp_c = ((char *)p_map) + 1; printf("char num. 2 = %c\n", *temp_c); temp_i = (short *) ((char *) p_map+1); printf("short = %hd\n", *temp_i); } This code accesses a txt file, called systabina.txt, one line long that is: Questo file ha lo scopo di determinare eventuali problemi di memory fault 2) Compile it using HP compiler in this way: %> cc +u1 -o mappa mappa.c 3) Run mappa and obtain the following result: %> mappa char num. 2 = u short = 30053 4) Now compile it without +u1 flag and run it %> cc -o mappa mappa.c %> mappa char num. 2 = u (Bus error core dumped) 5) If you try with gcc you obtain the same result: %> gcc -o mappa mappa.c %> mappa char num. 2 = u (Bus error core dumped) We would like to find the correspondent flag +u1 for gcc or adding a define in the code as workaround. We cannot strongly modify the code. I mean each structure or similar. Can someone help us? Thank you Sent via Deja.com http://www.deja.com/ Before you buy.