[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3493.0. "PSI - Point 25902" by KZIN::ASAP () Wed Apr 16 1997 04:56

    Company Name :  PSI - Point 25902
    Contact Name :  Frank Brockmann
    Phone        :  06021/366-0
    Fax          :  06021/366-112
    Email        :  [email protected]
    Date/Time in :  16-APR-1997 08:56:20
    Entered by   :  Nick Hudson
    SPE center   :  REO

    Category     :  vms
    OS Version   :  
    System H/W   :  


    Brief Description of Problem:
    -----------------------------

From:	RDGENG::MRGATE::"RDGMTS::PMDF::mail.dec.com::LennonD" 15-APR-1997 17:20:54.82
To:	RDGENG::ASAP
CC:	
Subj:	POINT 25902. PSI

From:	NAME: Declan Lennon <[email protected]@PMDF@INTERNET>
To:	NAME: '[email protected]' <IMCEAX400-c=US+3Ba=+20+3Bp=DIGITAL+3Bo=SBUEURMFG+3Bdda+3ASMTP=asap+40reo+2Emts+2Edec+2Ecom+3B@mail.dec.com@PMDF@INTERNET>

Hello -

POINT Log Number	 25902
Company Name 	PSI
Engineers name	Frank Brockmann
Telephone Number 		06021/366-0
Fax Number		06021/366-112
E-mail Address	 [email protected]

Operating System, Version	OpenVMS
Platform			Alpha

Problem Statement		

The following is a mail from Herr. Brockmann, PSI, roughly translated 
as:

As you can see in the following sample-program, using a C++ compiler 
the procedure name of a C routine with the extension _XI is provided. 
Not with the C compiler.

Is there a C++ compiler-switc that tells the compiler to behave as a C 
compiler?

What is necessary to call a C-function from a Pascal module?

Date: 14-Apr-1997 04:31pm
From: [email protected]@PMDF@INTERNET

  Subject:  Compilierung von C-Sourcen mit C++ Compiler zu Hd. 
H.Lennon


PSI Aktiengesellschaft			Boschweg 6			Telefon	06021/366-0
fuer Produkte und Systeme			63741 
Aschaffenburg		Telefax	06021/366-112
der Informationstechnologie			Geschaeftsbereich DL

Frank Brockmann




ASAP-Euro
Ballybrit Indistrial Park
Galway, Ireland

zu. Hd. H. Lennon



Betrfeff:  Compilierung von C-Sourcen mit C++ Compiler und Einbinden
               der C-Subroutinen in Pascal-Module.



Sehr geehrter H. Lennon,

wie im nachfolgenden Beispiel-Programm zu sehen ist, wird bei  der
Compilierung mit einem C++ Compiler der Procedurename einer
C-Subroutine mit der Extention __XI versehen (Sympol Name).
Bei der Compilierung mit einem C Compiler nicht.

Gibt es einen C++ Compiler-Switch der den C++ Compiler anweist
sich wie ein C-Compiler zu verhalten ?

Was ist alles notwendig um eine C-Function aus einem Pascal-Modul
herraus aufrufen zu koennen ?

Beispiel-Programm:
------------------------



/********************************************************************
* ******* *   C_SUB.C
**********************************************************************  

*****/

#include <stdio.h>
#include <string.h>

test_procedure(int yyy)
{

printf("C-Test-Procedure aus c_sub.c %d\n",yyy);

}
[End of file]



/*********************************************************************  

******* *   C_MAIN.C
**********************************************************************  

*****/

#include <stdio.h>
#include <string.h>

extern test_procedure(int yyy);


main()
{

printf("hallo test_procedure \n");

test_procedure(1);

}
[End of file]


{-----------------------------------------------------------------}
{File_name :PAS_MAIN.PAS}
{------------------------------------------------------------------}
PROGRAM test(input,output);

[EXTERNAL]procedure test_procedure__XI(yyy :integer ); extern;
{[EXTERNAL]procedure test_procedure(yyy :integer ); extern;}
[EXTERNAL]procedure test_procedure_pas(yyy :integer ); extern;

BEGIN
   writeln("test");
   test_procedure__xi(1);
   {test_procedure(1);}
   writeln("ende");
END.
[End of file]




$cxx c_sub.c
$cxx c_main.c
$pas pas_main.pas

$link c_main,c_sub/map=c_main.map
$run  c_main
hallo test_procedure
C-Test-Procedure aus c_sub.c 1

$link pas_main,c_sub/map=pas_main.map
$run  pas_main
test
C-Test-Procedure aus c_sub.c 2128493256
ende





Auszug aus c_main.map

                                                +-----------------+ !
                                                Symbols By Name !
                                                +-----------------+

Symbol                                           Value       Symbol 
 ----------                                         -----
MAIN                                             00010000-R
TEST_PROCEDURE__XI             00010090-R 
__MAIN                                         00010048-R 




          Key for special characters above:
                +--------------------+
                ! *  - Undefined     !
                ! A  - Alias Name    !
                ! I  - Internal Name !
                ! U  - Universal     !
                ! R  - Relocatable   !
 Buffer: C_MAIN.MAP



Auszug aus pas_main.map



                                                +-----------------+ !
                                                Symbols By Name !
                                                +-----------------+

Symbol                                                  Value
TEST_PROCEDURE__XI              00010080-R



          Key for special characters above:
                +--------------------+
                ! *  - Undefined     !
                ! A  - Alias Name    !
                ! I  - Internal Name !
                ! U  - Universal     !
                ! R  - Relocatable   !
                ! X  - External      !
                ! WK - Weak          !
 Buffer: PAS_MAIN.MAP





In replying, please use [email protected]




RFC-822-headers:
Received: from reoexc1.reo.dec.com by rg71rw.reo.dec.com (PMDF V5.0-7 #15552)
 id <[email protected]> for [email protected]; Tue,
 15 Apr 1997 16:22:50 +0100
Received: by reoexc1.reo.dec.com with SMTP
 (Microsoft Exchange Server Internet Mail Connector Version 4.0.994.63)
 id <[email protected]>; Tue, 15 Apr 1997 16:25:26 +0100
X-Mailer: Microsoft Exchange Server Internet Mail Connector Version 4.0.994.63
T.RTitleUserPersonal
Name
DateLines
3493.1KZIN::HUDSONThat&#039;s what I thinkWed Apr 16 1997 06:5684
From:	DEC:.REO.REOVTX::HUDSON       "[email protected] - UK Software
Partner Engineering 830-4121" 16-APR-1997 10:55:34.00
To:	nm%vbormc::"[email protected]"
CC:	HUDSON
Subj:	RE: POINT 25902. Pascal call c++ function

Guten Tag Herr Frank Brockmann

Meine Deutsche is nicht gut, aber vielleicht diese Beispiel-Programm ist fur
Sie ein Antwort....

Regards

Nick Hudson
Digital Software Partner Engineering


// FUNC.CXX
#include <iostream.h>
extern "C"		// This prevents "name mangling" (or "name decoration")
void test_procedure()
{
        cout << "Guten Tag!!" << endl;
}


(* MAIN.PAS *)
program main(input,output);
[external] procedure test_procedure; extern;
begin
        writeln("I am pascal, I will call the C++ procedure now...");
        test_procedure;
        writeln("here is the pascal again");
end.

$ pas main
$ cxx func
$ lin main,func
$ run main
I am pascal, I will call the C++ procedure now...
Guten Tag!!
here is the pascal again
$


If you have many functions, you can say:

// C++ header file
#if defined __cplusplus
extern "C" {
#endif
void proc1() 
{
.
.
.
}

void proc2()
{
.
.
.
}

.
.

#if defined __cplusplus
}
#endif



See
  "Using C++ for OpenVMS Systems" 
	section 3.1.1 "Providing C and C++ linkage"
	section 1.5 "Name Demangling"

  "Annotated C++ Reference Manual" (Stroustrup & Ellis)
	section 7.4 "Linkage Specifications"
	section 7.1c .. 7.3c "Commentary"