1844022 Members
2616 Online
110226 Solutions
New Discussion

Need help on C language.

 
ALPER ONEY
Advisor

Need help on C language.

hi,
I would lke to write a sonic mq client for Hp-UX by using C language. So I get some basic code examples from the vendor. Because this samples code require aCC (HP a++) software , I get a trial version of this program. Here is the script I use in order to compile the examples:
archtype=HPUX
cflags="-g +Z -D_RWSTD_MULTI_THREAD -D_REENTRANT -D_THREAD_SAFE -DUSE_PTHREADS"
ldflags="-AA -ldld -lm -lsmq -lpthread -lstd_v2 -Wl,+s"
cc=/opt/aCC/bin/aCC
var=""
$cc $cflags -DUNIX -D$archtype $var -I$SMQROOT/include -L$SMQROOT/bin/$BUILDMODE $ldflags -o $1 $1.c

What my problem is that I would like to modify the source written in C and of course compile the code again.
Here is the script I use with cc compiler when I need embedded C applications:
/ase/OCS-12_0/bin/cpre -m -I $SMQROOT/include $1.cp
cc -Ae -g -I. -I/ase/OCS-12_0/include +DA2.0N -DDEBUG -Daxposf=1 -L/ase/OCS-12_0/lib -c $1.c
cc -Ae -g -I. -I/ase/OCS-12_0/include +DA2.0N -DDEBUG -Daxposf=1 -L/ase/OCS-12_0/lib -c /ase/OCS-12_0/include/sybesql.c
cc -Ae $1.o sybesql.o /ase/OCS-12_0/lib/libct.a /ase/OCS-12_0/lib/libcs.a /ase/OCS-12_0/lib/libcomn.a /ase/OCS-12_0/lib/libtcl.a
/ase/OCS-12_0/lib/libinsck.sl /ase/OCS-12_0/lib/libintl.a -lm -o $1


Does anybody help me about how I can mix embedded sql/C and sonic mq(aC++) feautures in one executable.
Thanx in advance.
Regards
ALPER ONEY
never ever give up.
1 REPLY 1
Mike Stroyan
Honored Contributor

Re: Need help on C language.

You can freely mix .o files from the aCC compiler with .o files from the cc compiler. It works best to have a main program that is written in c++.
When you want to call c functions from aCC functions you need to use a declaration to tell the aCC compiler to use a c binding.

extern "C" {
int my_c_function(int p);
}

int my_aCC_function(void)
{
return my_c_function(7);
}

You can also define aCC functions inside of an extern "C" to make them callable from c.