How To Accessing C++ Class objects in C : getting error fatal error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sachinv1821@gmail.com

    How To Accessing C++ Class objects in C : getting error fatal error

    hi ,
    i am Getting this Error
    fatal error C1189: #error : "eh.h is only for C++!"
    my Problem is i am Having C++ librabry and Appropriate .h file
    i want to Access Them is .c File Files.....
    to Be More Specific i am Creating a C++ Object in a C file...
    this Giving me the error!!! :(

    can Any Body Please Help me


    How to Access the C++ object in C file...
    Thanks In Advance :)
  • tragomaskhalos

    #2
    Re: How To Accessing C++ Class objects in C : getting error fatal

    On Jan 7, 11:17 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
    wrote:
    hi ,
    i am Getting this Error
    fatal error C1189: #error : "eh.h is only for C++!"
    my Problem is i am Having C++ librabry and Appropriate .h file
    i want to Access Them is .c File Files.....
    to Be More Specific i am Creating a C++ Object in a C file...
    this Giving me the error!!! :(
    >
    can Any Body Please Help me
    >
    How to Access the C++ object in C file...
    Thanks In Advance :)
    In general, you can't.
    You can provide a procedural interface instead,
    and declare it in a header file like this:

    #ifdef __cplusplus
    extern "C" {
    #endif
    void some_function(i nt, char*, double); // or whatever
    #ifdef __cplusplus
    }
    #endif

    This can then be included from both C and C++.

    Comment

    • sachinv1821@gmail.com

      #3
      Re: How To Accessing C++ Class objects in C : getting error fatal

      On Jan 7, 4:32 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
      wrote:
      On Jan 7, 11:17 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
      wrote:
      >
      hi ,
      i am Getting this Error
      fatal error C1189: #error : "eh.h is only for C++!"
      my Problem is i am Having C++ librabry and Appropriate .h file
      i want to Access Them is .c File Files.....
      to Be More Specific i am Creating a C++ Object in a C file...
      this Giving me the error!!! :(
      >
      can Any Body Please Help me
      >
      How to Access the C++ object in C file...
      Thanks In Advance :)
      >
      In general, you can't.
      You can provide a procedural interface instead,
      and declare it in a header file like this:
      >
      #ifdef __cplusplus
      extern "C" {
      #endif
      void some_function(i nt, char*, double); // or whatever
      #ifdef __cplusplus}
      >
      #endif
      >
      This can then be included from both C and C++.
      Ya i can Do that But There are Many Class and there are many
      Functions....so Writting the Wrapper For Each is Not Possible..
      so is there any Alternative method or any Buit-in COde Genarator S/w
      that can Do this Task!!
      Thanks For the Reply :)! waiting ahead For Reply!!

      Comment

      • ciccio

        #4
        Re: How To Accessing C++ Class objects in C : getting error fatal

        Hi,
        How to Access the C++ object in C file...
        Please have a look at the following page



        Regards

        Comment

        • tragomaskhalos

          #5
          Re: How To Accessing C++ Class objects in C : getting error fatal

          On Jan 7, 11:41 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
          wrote:
          >
          Ya i can Do that But There are Many Class and there are many
          Functions....so Writting the Wrapper For Each is Not Possible..
          so is there any Alternative method or any Buit-in COde Genarator S/w
          that can Do this Task!!
          Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
          >
          If this is the case why on earth are you trying to do this from C?
          Rename your .c files to .cpp and compile them as C++, why don't you?

          Comment

          • sachinv1821@gmail.com

            #6
            Re: How To Accessing C++ Class objects in C : getting error fatal

            On Jan 7, 4:49 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
            wrote:
            On Jan 7, 11:41 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
            wrote:
            >
            >
            >
            Ya i can Do that But There are Many Class and there are many
            Functions....so Writting the Wrapper For Each is Not Possible..
            so is there any Alternative method or any Buit-in COde Genarator S/w
            that can Do this Task!!
            Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
            >
            If this is the case why on earth are you trying to do this from C?
            Rename your .c files to .cpp and compile them as C++, why don't you?
            Thanks For Reply i MIght have Done that Problem i am Doing Something
            in PreDefined Frame-Work Which is Written in C and i got a Third Party
            Library which is in C++ ,i am Not Getting HOw to Hormonize these
            two ... [:( ]
            since i cannt Change the Framework as well i cannt do anythig in Third
            Party Lib.......

            Comment

            • tragomaskhalos

              #7
              Re: How To Accessing C++ Class objects in C : getting error fatal

              On Jan 7, 11:54 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
              wrote:
              On Jan 7, 4:49 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
              wrote:
              >
              On Jan 7, 11:41 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
              wrote:
              >
              Ya i can Do that But There are Many Class and there are many
              Functions....so Writting the Wrapper For Each is Not Possible..
              so is there any Alternative method or any Buit-in COde Genarator S/w
              that can Do this Task!!
              Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
              >
              If this is the case why on earth are you trying to do this from C?
              Rename your .c files to .cpp and compile them as C++, why don't you?
              >
              Thanks For Reply i MIght have Done that Problem i am Doing Something
              in PreDefined Frame-Work Which is Written in C and i got a Third Party
              Library which is in C++ ,i am Not Getting HOw to Hormonize these
              two ... [:( ]
              since i cannt Change the Framework as well i cannt do anythig in Third
              Party Lib.......
              In that case you will have to isolate the code that accesses the 3rd
              party library into a C++ module and provide a procedural interface
              to that module that's callable from C using the technique I described
              before.

              Comment

              • sachin.vastrad@gmail.com

                #8
                Re: How To Accessing C++ Class objects in C : getting error fatal

                On Jan 7, 5:14 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
                wrote:
                On Jan 7, 11:54 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                wrote:
                >
                >
                >
                >
                >
                On Jan 7, 4:49 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
                wrote:
                >
                On Jan 7, 11:41 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                wrote:
                >
                Ya i can Do that But There are Many Class and there are many
                Functions....so Writting the Wrapper For Each is Not Possible..
                so is there any Alternative method or any Buit-in COde Genarator S/w
                that can Do this Task!!
                Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text-
                >
                If this is the case why on earth are you trying to do this from C?
                Rename your .c files to .cpp and compile them as C++, why don't you?
                >
                Thanks For Reply i MIght have Done that Problem i am Doing Something
                in PreDefined Frame-Work Which is Written in C and i got a Third Party
                Library which is in C++ ,i am Not Getting HOw to Hormonize these
                two ... [:( ]
                since i cannt Change the Framework as well i cannt do anythig in Third
                Party Lib.......
                >
                In that case you will have to isolate the code that accesses the 3rd
                party library into a C++ module and provide a procedural interface
                to that module that's callable from C using the technique I described
                before.- Hide quoted text -
                >
                - Show quoted text -
                ya I think this ll be Better Option For ME
                Thank you :)

                Comment

                • Ioannis Gyftos

                  #9
                  Re: How To Accessing C++ Class objects in C : getting error fatal

                  On Jan 7, 1:54 pm, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                  wrote:
                  Thanks For Reply i MIght have Done that Problem i am Doing Something
                  in PreDefined Frame-Work Which is Written in C and i got a Third Party
                  Library which is in C++ ,i am Not Getting HOw to Hormonize these
                  two ... [:( ]
                  since i cannt Change the Framework as well i cannt do anythig in Third
                  Party Lib.......
                  I don't think I'm such a weirdo, but this seriously hurts my eyes.
                  Please post in standard English, which is also a quite an efficient
                  way to get you more helpful responses :)

                  Comment

                  • James Kanze

                    #10
                    Re: How To Accessing C++ Class objects in C : getting error fatal

                    On Jan 7, 12:17 pm, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                    wrote:
                    i am Getting this Error
                    fatal error C1189: #error : "eh.h is only for C++!"
                    I'm not familiar with the compiler you are using (or maybe I
                    am---I don't know what compiler you are using), but the text of
                    the error message seems very, very clear. The author of this
                    file, for whatever reasons, did *not* want his header processed
                    by a C compiler. Which probably means that you'll have to
                    either give up using the library, or wrap it in an additional C
                    layer which can be called from C++.

                    Note that the error message says "#error". That sounds like the
                    compiler has encountered an #error preprocessor directive.
                    Perhaps something like:

                    #ifndef __cplusplus
                    #error eh.h is only for C++
                    #endif

                    You could always try to invoke the C compiler with something
                    like -D__cplusplus or /D__cplusplus, but this is undefined
                    behavior, and of course, if the original author didn't want the
                    file compiled with a C compiler, there is probably a reason.
                    my Problem is i am Having C++ librabry and Appropriate .h file
                    i want to Access Them is .c File Files.....
                    You can't.
                    to Be More Specific i am Creating a C++ Object in a C file...
                    this Giving me the error!!! :(
                    You can't.
                    can Any Body Please Help me
                    How to Access the C++ object in C file...
                    If you compile with C, there is no way that you're be able to
                    instantiate a C++ class that is not a POD. If you compile with
                    C, there's no way you can do anything not allowed in C. (Also,
                    if you compile with C, this forum really isn't the appropriate
                    place to post your question. comp.lang.c would be more
                    appropriate, but I can just imagine the response you'll get
                    there.)

                    --
                    James Kanze (GABI Software) mailto:james.ka nze@gmail.com
                    Conseils en informatique orient�e objet/
                    Beratung in objektorientier ter Datenverarbeitu ng
                    9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34

                    Comment

                    • sachinv1821@gmail.com

                      #11
                      Re: How To Accessing C++ Class objects in C : getting error fatal

                      On Jan 7, 5:14 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
                      wrote:
                      On Jan 7, 11:54 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                      wrote:
                      >
                      >
                      >
                      On Jan 7, 4:49 pm, tragomaskhalos <dave.du.verg.. .@logicacmg.com >
                      wrote:
                      >
                      On Jan 7, 11:41 am, "sachinv1...@gm ail.com" <sachinv1...@gm ail.com>
                      wrote:
                      >
                      Ya i can Do that But There are Many Class and there are many
                      Functions....so Writting the Wrapper For Each is Not Possible..
                      so is there any Alternative method or any Buit-in COde Genarator S/w
                      that can Do this Task!!
                      Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
                      >
                      If this is the case why on earth are you trying to do this from C?
                      Rename your .c files to .cpp and compile them as C++, why don't you?
                      >
                      Thanks For Reply i MIght have Done that Problem i am Doing Something
                      in PreDefined Frame-Work Which is Written in C and i got a Third Party
                      Library which is in C++ ,i am Not Getting HOw to Hormonize these
                      two ... [:( ]
                      since i cannt Change the Framework as well i cannt do anythig in Third
                      Party Lib.......
                      >
                      In that case you will have to isolate the code that accesses the 3rd
                      party library into a C++ module and provide a procedural interface
                      to that module that's callable from C using the technique I described
                      before.
                      hello there i got this Problem Solved (i written a wrapper above the c+
                      + lib)
                      now its Compling and linking correctly! But again i encountered new
                      problem
                      Actually i made this C project as a ACM driver / Dll File now when i
                      try to load the DLL/ACM its not not loding flaging the error no
                      998(invalid access of Memory...)
                      if any one know please help me

                      Comment

                      Working...