LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc and xlc (https://www.linuxquestions.org/questions/programming-9/gcc-and-xlc-736636/)

eljuventino 06-30-2009 04:46 AM

gcc and xlc
 
hi everyone!!i'm very happy to be one of the most great linux forums in the world and thanks for all great work that u do here!!
i'm new to linux i have some basic but still newer!!i have a project that i work on!!it's a product that has been installed and compiled in AIX system with xlc compiler!!my job here is to migrate this one to red hat linux entreprise 5 and compile all the makefile with GCC
i'l traying to do the max to find a similarity between xlc and gcc but i'm stuck in one or two option that i can't figure out the solution specially -D option
there is one example of makefile that i do compile but with using the line that contains -D option:
gcc -c -DAIX41_OPSYS -I/home/oracle/Open2/COMMON/inc -I/home/oracle/Open2/dbg -DSYSV -D_NO_LONGLONG -I../inc -g -g -c afp_dump.c
i’m gratful if someone help me resolve this !!

jf.argentino 06-30-2009 06:24 AM

Hello,
the -D option tells to GCC preprocessor to define the symbol next to it, so in the given line afp_dump.c is compiled with the AIX41_OPSYS symbol defined, as if you've add "define AIX41_OPSYS" in the file.
There is strange things in the line I can see: -g and -c options appear twice, that certainly means that the Makefile isn't well wrotten.
If you need more info "man gcc" is the way to go.

eljuventino 06-30-2009 08:22 AM

thanks man for your answer !!as i understand i have to define AIX41_OPSYS in the file afp_dump.c and the compilation will go correctly if u can give me an exeample that explain how this -D option works!!anyway thanks man for your replies again!!!

jf.argentino 06-30-2009 09:12 AM

Nooo!
-DAIX41_OPSYS define the AIX41_OPSYS symbol _AS_IF_ you add "#define AIX41_OPSYS" in every src files you're compiling.
Try this:
Code:

#include <stdio.h>
int main (void) {
  #ifdef MY_SYMBOL
  printf ("MY_SYMBOL is defined\n");
  #else
  printf ("MY_SYMBOL is not defined\n");
  #endif
  retun 0;
}

compile it with and without -DMY_SYMBOL option.

As you want to port from AIX to LINUX I guess that you have to port every pieces of code surrounded by "#ifdef AIX41_OPSYS"

eljuventino 06-30-2009 09:22 AM

waaaaaaaw!!thanks man ,u are the best!!! now i see what -D option means !!!just one question what do u mean that i have to port every pieces of code surrounded by "#ifdef AIX41_OPSYS"!!belive me your answer was great and after 2 weeks in saerching in the net and no result, u come with a simple and good explaination !!!thanks again !!!

eljuventino 06-30-2009 10:39 AM

i see what do u mean know!!thanks a lot for the help it was very helpful thanks again!!

eljuventino 07-01-2009 03:47 AM

thanks man i foud AIX41_OPSYS in one of my .c files and i found this code!!u think that i can to port to linux:
#if (defined(UNIX_OPSYS) && !defined(sun)) || defined(IRIX53_OPSYS) || defined(AIX41_OPSYS) || defined(AIX)
/****************************************************************************/
/* Function: set_signal() - VERSIONE UNIX */
/* Date L.M.: 26-May-1998 */
/* Description: Assign sig_handler() for all signals */
/****************************************************************************/

void set_signal()
{
struct sigaction act = { 0, 0, 0 };
int sig;

act.sa_handler = sig_handler;

for (sig = 1; sig < SIGMAX; sig++)
if (sig != SIGKILL && sig != 21 && sig != SIGCHLD)
sigaction(sig, &act, 0);

}

#endif

#ifdef sun
/****************************************************************************/
/* Function: set_signal() */
/* Date L.M.: 23-Nov-1998 */
/* Description: Assign sig_handler() for all signals */
/****************************************************************************/

void set_signal()
{
struct sigaction act = { 0, 0, 0 };
int sig;

act.sa_handler = sig_handler;

for (sig = 1; sig < SIGRTMAX; sig++)
if (sig != SIGKILL && sig != SIGTTIN && sig != SIGCHLD)
sigaction(sig, &act, 0);

}


#endif /* ifdef sun */

bigearsbilly 07-02-2009 10:13 AM

there are some differences with signals between unix versions.

you must read the man signal pages for AIX and compare with linux to see if you can work
out how to rewrite the signal functions.

It looks at a cursory glance if it's simply disabling the signals.

I think in older unix versions the sigaction needs to be reset after a catch.

though, of course, i could be wrong.

you could always try it!


All times are GMT -5. The time now is 02:40 PM.