Problem with ADA file executed by a c++(UsrAppInit) in VXWorks 6.7(workspace-4)?












0















I have a file build and compiled correctly in ADA (a simple Hello world). I want to execute the file .o from a c++ using taskspawn. To do that I have read that you must declare in the c++ something like that:



...



#include <taskLib.h>

/* Ada binder-generated main - ADA_MAIN is passed as a macro from the makefile */

extern void ADA_MAIN(void);

void UsrAppInit()

{

int stackSize = 0x80000;


int spawnFlags = VX_FP_TASK;

/* MAIN_TASK_NAME is passed as a macro from the makefile */
char * mainTaskName = (char *) MAIN_TASK_NAME;

int priority = 100;

/* Spawn Ada environment task */

taskSpawn(mainTaskName, priority, spawnFlags, stackSize,
(FUNCPTR) ADA_MAIN, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}


to complete the process I have declared the ADA_MAIN as a MACRO in makefile (in my case the makefile is makefile.mk)



(MAIN_ADA pathOfmyADAexe and MAIN_TASK_NAME "the procedure of the helloworld")



but the MACRO are not recognized in the process so I have error in compilation for MAIN_TASK_NAME and ADA_MAIN. Any suggestion about how am I missing? I could also do in different way but how?










share|improve this question


















  • 1





    You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

    – Joakim Strandberg
    Nov 13 '18 at 13:49






  • 1





    If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

    – Simon Wright
    Nov 13 '18 at 14:56











  • If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

    – Simon Wright
    Nov 14 '18 at 11:52











  • Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

    – Giovanni
    Nov 15 '18 at 7:07


















0















I have a file build and compiled correctly in ADA (a simple Hello world). I want to execute the file .o from a c++ using taskspawn. To do that I have read that you must declare in the c++ something like that:



...



#include <taskLib.h>

/* Ada binder-generated main - ADA_MAIN is passed as a macro from the makefile */

extern void ADA_MAIN(void);

void UsrAppInit()

{

int stackSize = 0x80000;


int spawnFlags = VX_FP_TASK;

/* MAIN_TASK_NAME is passed as a macro from the makefile */
char * mainTaskName = (char *) MAIN_TASK_NAME;

int priority = 100;

/* Spawn Ada environment task */

taskSpawn(mainTaskName, priority, spawnFlags, stackSize,
(FUNCPTR) ADA_MAIN, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}


to complete the process I have declared the ADA_MAIN as a MACRO in makefile (in my case the makefile is makefile.mk)



(MAIN_ADA pathOfmyADAexe and MAIN_TASK_NAME "the procedure of the helloworld")



but the MACRO are not recognized in the process so I have error in compilation for MAIN_TASK_NAME and ADA_MAIN. Any suggestion about how am I missing? I could also do in different way but how?










share|improve this question


















  • 1





    You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

    – Joakim Strandberg
    Nov 13 '18 at 13:49






  • 1





    If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

    – Simon Wright
    Nov 13 '18 at 14:56











  • If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

    – Simon Wright
    Nov 14 '18 at 11:52











  • Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

    – Giovanni
    Nov 15 '18 at 7:07
















0












0








0








I have a file build and compiled correctly in ADA (a simple Hello world). I want to execute the file .o from a c++ using taskspawn. To do that I have read that you must declare in the c++ something like that:



...



#include <taskLib.h>

/* Ada binder-generated main - ADA_MAIN is passed as a macro from the makefile */

extern void ADA_MAIN(void);

void UsrAppInit()

{

int stackSize = 0x80000;


int spawnFlags = VX_FP_TASK;

/* MAIN_TASK_NAME is passed as a macro from the makefile */
char * mainTaskName = (char *) MAIN_TASK_NAME;

int priority = 100;

/* Spawn Ada environment task */

taskSpawn(mainTaskName, priority, spawnFlags, stackSize,
(FUNCPTR) ADA_MAIN, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}


to complete the process I have declared the ADA_MAIN as a MACRO in makefile (in my case the makefile is makefile.mk)



(MAIN_ADA pathOfmyADAexe and MAIN_TASK_NAME "the procedure of the helloworld")



but the MACRO are not recognized in the process so I have error in compilation for MAIN_TASK_NAME and ADA_MAIN. Any suggestion about how am I missing? I could also do in different way but how?










share|improve this question














I have a file build and compiled correctly in ADA (a simple Hello world). I want to execute the file .o from a c++ using taskspawn. To do that I have read that you must declare in the c++ something like that:



...



#include <taskLib.h>

/* Ada binder-generated main - ADA_MAIN is passed as a macro from the makefile */

extern void ADA_MAIN(void);

void UsrAppInit()

{

int stackSize = 0x80000;


int spawnFlags = VX_FP_TASK;

/* MAIN_TASK_NAME is passed as a macro from the makefile */
char * mainTaskName = (char *) MAIN_TASK_NAME;

int priority = 100;

/* Spawn Ada environment task */

taskSpawn(mainTaskName, priority, spawnFlags, stackSize,
(FUNCPTR) ADA_MAIN, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}


to complete the process I have declared the ADA_MAIN as a MACRO in makefile (in my case the makefile is makefile.mk)



(MAIN_ADA pathOfmyADAexe and MAIN_TASK_NAME "the procedure of the helloworld")



but the MACRO are not recognized in the process so I have error in compilation for MAIN_TASK_NAME and ADA_MAIN. Any suggestion about how am I missing? I could also do in different way but how?







c++ macros ada vxworks






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 7:37









GiovanniGiovanni

11




11








  • 1





    You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

    – Joakim Strandberg
    Nov 13 '18 at 13:49






  • 1





    If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

    – Simon Wright
    Nov 13 '18 at 14:56











  • If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

    – Simon Wright
    Nov 14 '18 at 11:52











  • Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

    – Giovanni
    Nov 15 '18 at 7:07
















  • 1





    You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

    – Joakim Strandberg
    Nov 13 '18 at 13:49






  • 1





    If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

    – Simon Wright
    Nov 13 '18 at 14:56











  • If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

    – Simon Wright
    Nov 14 '18 at 11:52











  • Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

    – Giovanni
    Nov 15 '18 at 7:07










1




1





You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

– Joakim Strandberg
Nov 13 '18 at 13:49





You haven't written which Ada compiler you are using but assuming it's GNAT the C/C++ application must first call adainit Before any call to an Ada subprogram and the last action of the C/C++ application is to call adafinal. Maybe these calls are hidden in the ADA_MAIN macro mentioned above? gcc.gnu.org/onlinedocs/gnat_ugn/…

– Joakim Strandberg
Nov 13 '18 at 13:49




1




1





If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

– Simon Wright
Nov 13 '18 at 14:56





If your compiler is GNAT, I’ll attempt an answer. If not, go to your compiler manuals/vendor.

– Simon Wright
Nov 13 '18 at 14:56













If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

– Simon Wright
Nov 14 '18 at 11:52





If you think there’s something wrong with your macro (why do you capitalise it?) you should add it to your question.

– Simon Wright
Nov 14 '18 at 11:52













Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

– Giovanni
Nov 15 '18 at 7:07







Sorry for the delay, the Ada compiler is GNAT PRO 18.2. the Macro are capitalized according to the example that I see on-line. adainit() and adafinal are not recognized during the building procedure.

– Giovanni
Nov 15 '18 at 7:07














1 Answer
1






active

oldest

votes


















1














I don’t know about your ADA_MAIN, and you don't tell us what your MACRO is, so it's a little hard to talk about them. Also, it's a while since I used VxWorks (and, then, we were supported, so had access to a cross-compiler that did the build for us: and our main program was in Ada).



That said, your problem comes down to building a program with Ada components where the main program isn't in Ada.



Ada programs need elaboration. This is the process that calls in all the components of the runtime library and arranges for them to be initialized in the right order. What components, you ask? well, for instance, there's the obvious Ada.Text_IO; and there's the less-obvious things, such as exception handling.



The elaboration code is generated using gnatbind.



Given this hello.adb



with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line ("hello!");
end Hello;


you really need to supply a specification, as otherwise the compiler will generate a linker name such as __ada_hello; take control by hello.ads,



procedure Hello with
Export,
Convention => C,
External_Name => "hello";


You'll be using a cross-compilation suite. The components are prefixed by the target name, e.g. powerpc-wrs-vxworks-gnatmake, arm-eabi-gnatbind, but I'll just use the bare component name below.



$ gnatmake -c hello.adb


which generates hello.o, hello.ali (if the program was more complicated, it'd compile the closure too).



Now bind:



$ gnatbind -n -Lhello -static hello.ali


where





  • -n : main program not in Ada


  • -Lhello: adainit, adafinal renamed helloinit, hellofinal


  • -static: pretty sure VxWorks doesn't support shared libraries?


generating b~hello.ads, b~hello.adb (depending on the compiler release, the ~ may be replaced by e.g. double underscore). Compile:



$ gnatmake -c b~hello.adb


Now, to call from C++. you need to tell the compiler about the symbols in the Ada code, in e.g. hello.h:



extern "C" {
void helloinit();
void hellofinal();
void hello();
}


and then the main program in main.cc:



#include "hello.h"

int main() {
helloinit();
hello();
hellofinal();
}


which leaves you with the C++ compile and link, which needs the Ada runtime in libgnat.a and (for tasking) libgnarl.a, and is of course very compiler- and installation-specific: here, on the macOS host, I used



$ g++ main.cc b~hello.o hello.o /opt/gcc-8.1.0/lib/gcc/x86_64-apple-darwin15/8.1.0/adalib/libgnat.a
$ ./a.out
hello!




Translating this to the VxWorks context, I'd say that you'd call helloinit() from your main program (you probably won't need hellofinal()), and pass hello to taskSpawn() in place of your ADA_MAIN.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276028%2fproblem-with-ada-file-executed-by-a-cusrappinit-in-vxworks-6-7workspace-4%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I don’t know about your ADA_MAIN, and you don't tell us what your MACRO is, so it's a little hard to talk about them. Also, it's a while since I used VxWorks (and, then, we were supported, so had access to a cross-compiler that did the build for us: and our main program was in Ada).



    That said, your problem comes down to building a program with Ada components where the main program isn't in Ada.



    Ada programs need elaboration. This is the process that calls in all the components of the runtime library and arranges for them to be initialized in the right order. What components, you ask? well, for instance, there's the obvious Ada.Text_IO; and there's the less-obvious things, such as exception handling.



    The elaboration code is generated using gnatbind.



    Given this hello.adb



    with Ada.Text_IO;
    procedure Hello is
    begin
    Ada.Text_IO.Put_Line ("hello!");
    end Hello;


    you really need to supply a specification, as otherwise the compiler will generate a linker name such as __ada_hello; take control by hello.ads,



    procedure Hello with
    Export,
    Convention => C,
    External_Name => "hello";


    You'll be using a cross-compilation suite. The components are prefixed by the target name, e.g. powerpc-wrs-vxworks-gnatmake, arm-eabi-gnatbind, but I'll just use the bare component name below.



    $ gnatmake -c hello.adb


    which generates hello.o, hello.ali (if the program was more complicated, it'd compile the closure too).



    Now bind:



    $ gnatbind -n -Lhello -static hello.ali


    where





    • -n : main program not in Ada


    • -Lhello: adainit, adafinal renamed helloinit, hellofinal


    • -static: pretty sure VxWorks doesn't support shared libraries?


    generating b~hello.ads, b~hello.adb (depending on the compiler release, the ~ may be replaced by e.g. double underscore). Compile:



    $ gnatmake -c b~hello.adb


    Now, to call from C++. you need to tell the compiler about the symbols in the Ada code, in e.g. hello.h:



    extern "C" {
    void helloinit();
    void hellofinal();
    void hello();
    }


    and then the main program in main.cc:



    #include "hello.h"

    int main() {
    helloinit();
    hello();
    hellofinal();
    }


    which leaves you with the C++ compile and link, which needs the Ada runtime in libgnat.a and (for tasking) libgnarl.a, and is of course very compiler- and installation-specific: here, on the macOS host, I used



    $ g++ main.cc b~hello.o hello.o /opt/gcc-8.1.0/lib/gcc/x86_64-apple-darwin15/8.1.0/adalib/libgnat.a
    $ ./a.out
    hello!




    Translating this to the VxWorks context, I'd say that you'd call helloinit() from your main program (you probably won't need hellofinal()), and pass hello to taskSpawn() in place of your ADA_MAIN.






    share|improve this answer






























      1














      I don’t know about your ADA_MAIN, and you don't tell us what your MACRO is, so it's a little hard to talk about them. Also, it's a while since I used VxWorks (and, then, we were supported, so had access to a cross-compiler that did the build for us: and our main program was in Ada).



      That said, your problem comes down to building a program with Ada components where the main program isn't in Ada.



      Ada programs need elaboration. This is the process that calls in all the components of the runtime library and arranges for them to be initialized in the right order. What components, you ask? well, for instance, there's the obvious Ada.Text_IO; and there's the less-obvious things, such as exception handling.



      The elaboration code is generated using gnatbind.



      Given this hello.adb



      with Ada.Text_IO;
      procedure Hello is
      begin
      Ada.Text_IO.Put_Line ("hello!");
      end Hello;


      you really need to supply a specification, as otherwise the compiler will generate a linker name such as __ada_hello; take control by hello.ads,



      procedure Hello with
      Export,
      Convention => C,
      External_Name => "hello";


      You'll be using a cross-compilation suite. The components are prefixed by the target name, e.g. powerpc-wrs-vxworks-gnatmake, arm-eabi-gnatbind, but I'll just use the bare component name below.



      $ gnatmake -c hello.adb


      which generates hello.o, hello.ali (if the program was more complicated, it'd compile the closure too).



      Now bind:



      $ gnatbind -n -Lhello -static hello.ali


      where





      • -n : main program not in Ada


      • -Lhello: adainit, adafinal renamed helloinit, hellofinal


      • -static: pretty sure VxWorks doesn't support shared libraries?


      generating b~hello.ads, b~hello.adb (depending on the compiler release, the ~ may be replaced by e.g. double underscore). Compile:



      $ gnatmake -c b~hello.adb


      Now, to call from C++. you need to tell the compiler about the symbols in the Ada code, in e.g. hello.h:



      extern "C" {
      void helloinit();
      void hellofinal();
      void hello();
      }


      and then the main program in main.cc:



      #include "hello.h"

      int main() {
      helloinit();
      hello();
      hellofinal();
      }


      which leaves you with the C++ compile and link, which needs the Ada runtime in libgnat.a and (for tasking) libgnarl.a, and is of course very compiler- and installation-specific: here, on the macOS host, I used



      $ g++ main.cc b~hello.o hello.o /opt/gcc-8.1.0/lib/gcc/x86_64-apple-darwin15/8.1.0/adalib/libgnat.a
      $ ./a.out
      hello!




      Translating this to the VxWorks context, I'd say that you'd call helloinit() from your main program (you probably won't need hellofinal()), and pass hello to taskSpawn() in place of your ADA_MAIN.






      share|improve this answer




























        1












        1








        1







        I don’t know about your ADA_MAIN, and you don't tell us what your MACRO is, so it's a little hard to talk about them. Also, it's a while since I used VxWorks (and, then, we were supported, so had access to a cross-compiler that did the build for us: and our main program was in Ada).



        That said, your problem comes down to building a program with Ada components where the main program isn't in Ada.



        Ada programs need elaboration. This is the process that calls in all the components of the runtime library and arranges for them to be initialized in the right order. What components, you ask? well, for instance, there's the obvious Ada.Text_IO; and there's the less-obvious things, such as exception handling.



        The elaboration code is generated using gnatbind.



        Given this hello.adb



        with Ada.Text_IO;
        procedure Hello is
        begin
        Ada.Text_IO.Put_Line ("hello!");
        end Hello;


        you really need to supply a specification, as otherwise the compiler will generate a linker name such as __ada_hello; take control by hello.ads,



        procedure Hello with
        Export,
        Convention => C,
        External_Name => "hello";


        You'll be using a cross-compilation suite. The components are prefixed by the target name, e.g. powerpc-wrs-vxworks-gnatmake, arm-eabi-gnatbind, but I'll just use the bare component name below.



        $ gnatmake -c hello.adb


        which generates hello.o, hello.ali (if the program was more complicated, it'd compile the closure too).



        Now bind:



        $ gnatbind -n -Lhello -static hello.ali


        where





        • -n : main program not in Ada


        • -Lhello: adainit, adafinal renamed helloinit, hellofinal


        • -static: pretty sure VxWorks doesn't support shared libraries?


        generating b~hello.ads, b~hello.adb (depending on the compiler release, the ~ may be replaced by e.g. double underscore). Compile:



        $ gnatmake -c b~hello.adb


        Now, to call from C++. you need to tell the compiler about the symbols in the Ada code, in e.g. hello.h:



        extern "C" {
        void helloinit();
        void hellofinal();
        void hello();
        }


        and then the main program in main.cc:



        #include "hello.h"

        int main() {
        helloinit();
        hello();
        hellofinal();
        }


        which leaves you with the C++ compile and link, which needs the Ada runtime in libgnat.a and (for tasking) libgnarl.a, and is of course very compiler- and installation-specific: here, on the macOS host, I used



        $ g++ main.cc b~hello.o hello.o /opt/gcc-8.1.0/lib/gcc/x86_64-apple-darwin15/8.1.0/adalib/libgnat.a
        $ ./a.out
        hello!




        Translating this to the VxWorks context, I'd say that you'd call helloinit() from your main program (you probably won't need hellofinal()), and pass hello to taskSpawn() in place of your ADA_MAIN.






        share|improve this answer















        I don’t know about your ADA_MAIN, and you don't tell us what your MACRO is, so it's a little hard to talk about them. Also, it's a while since I used VxWorks (and, then, we were supported, so had access to a cross-compiler that did the build for us: and our main program was in Ada).



        That said, your problem comes down to building a program with Ada components where the main program isn't in Ada.



        Ada programs need elaboration. This is the process that calls in all the components of the runtime library and arranges for them to be initialized in the right order. What components, you ask? well, for instance, there's the obvious Ada.Text_IO; and there's the less-obvious things, such as exception handling.



        The elaboration code is generated using gnatbind.



        Given this hello.adb



        with Ada.Text_IO;
        procedure Hello is
        begin
        Ada.Text_IO.Put_Line ("hello!");
        end Hello;


        you really need to supply a specification, as otherwise the compiler will generate a linker name such as __ada_hello; take control by hello.ads,



        procedure Hello with
        Export,
        Convention => C,
        External_Name => "hello";


        You'll be using a cross-compilation suite. The components are prefixed by the target name, e.g. powerpc-wrs-vxworks-gnatmake, arm-eabi-gnatbind, but I'll just use the bare component name below.



        $ gnatmake -c hello.adb


        which generates hello.o, hello.ali (if the program was more complicated, it'd compile the closure too).



        Now bind:



        $ gnatbind -n -Lhello -static hello.ali


        where





        • -n : main program not in Ada


        • -Lhello: adainit, adafinal renamed helloinit, hellofinal


        • -static: pretty sure VxWorks doesn't support shared libraries?


        generating b~hello.ads, b~hello.adb (depending on the compiler release, the ~ may be replaced by e.g. double underscore). Compile:



        $ gnatmake -c b~hello.adb


        Now, to call from C++. you need to tell the compiler about the symbols in the Ada code, in e.g. hello.h:



        extern "C" {
        void helloinit();
        void hellofinal();
        void hello();
        }


        and then the main program in main.cc:



        #include "hello.h"

        int main() {
        helloinit();
        hello();
        hellofinal();
        }


        which leaves you with the C++ compile and link, which needs the Ada runtime in libgnat.a and (for tasking) libgnarl.a, and is of course very compiler- and installation-specific: here, on the macOS host, I used



        $ g++ main.cc b~hello.o hello.o /opt/gcc-8.1.0/lib/gcc/x86_64-apple-darwin15/8.1.0/adalib/libgnat.a
        $ ./a.out
        hello!




        Translating this to the VxWorks context, I'd say that you'd call helloinit() from your main program (you probably won't need hellofinal()), and pass hello to taskSpawn() in place of your ADA_MAIN.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 '18 at 9:16

























        answered Nov 16 '18 at 9:05









        Simon WrightSimon Wright

        16.5k21836




        16.5k21836






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276028%2fproblem-with-ada-file-executed-by-a-cusrappinit-in-vxworks-6-7workspace-4%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma