350 pts.
 Create one program with a C and CPP modules
How can I create program with mixed modules? is it possible ? I create my modules in this way:
// int function1(parms) 
crtcmod ( LIB/MOD ) 
...
//int mehtod2( )
crtcppmod ( LIB/MOD2 )  
...
crtpgm ( LIB/CPPPGM ) MODULES ( LIB/MOD LIB/MOD2 ) 
fails with the message  "Definition not found for symbol function1___" how can I do it ? 
Thanks


Software/Hardware used:
v5r4
ASKED: April 25, 2012  4:11 PM
UPDATED: April 25, 2012  9:22 PM
  Help
 Approved Answer - Chosen by GraceP (Question Asker)

Yeah , never mind it was a dummy question, I was trying to get a program with modules compiled in c and in cpp :

uno.h :
<pre>
extern "C" {
int sum(int a , int b) ;
}
</pre>

uno.c
<pre>
int sum ( int a , int b ) {
return a + b;
}
</pre>

dos.cpp
<pre>
#include "uno.h"
int main (int argc , char ** argv ) {
int a = 9 ;
int b = 10 ;

int result = sum( a, b ) ;
printf ("Sum %d n", result );
return 0 ;
}
</pre>
WIth the keyword 'extern' and without the '#ifndef' of the h files(that I used in cpp before to transform int a C program) I could create the program successful.

Thanks Tom

ANSWERED:  Apr 25, 2012  9:22 PM (GMT)  by GraceP

 
Other Answers:

never mind it was a dummy question:
uno.h :
<pre>
extern “C” {
int sum(int a , int b) ;
}
</pre>

uno.c
<pre>
int suma ( int a , int b ) {
return a + b;
}
</pre>

dos.cpp
<pre>
#include “uno.h”
int main (int argc , char ** argv ) {
int a = 9 ;
int b = 10 ;

int result = suma ( a, b ) ;
printf (“Suma %d \n”, result );
return 0 ;
}
</pre>
it works mixing the c and cpp modules to create one PGM

Last Wiki Answer Submitted:  April 25, 2012  9:15 pm  by  GraceP   350 pts.
Latest Answer Wiki Contributors:  GraceP   350 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

“Definition not found for symbol function1___”

Where is ‘function1___’?

Actually, that looks like a C++ name. Because your code shows this line:

// int function1(parms) 

…I’d assume that you actually are attempting to reference a proc in your C module and its real name is ‘function1()’. Right?

It’s hard to tell because it’s not clear what code you’re showing. I can’t tell what language it’s supposed to be.

Tom

 109,995 pts.