Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. typedef enum c header to C#

typedef enum c header to C#

Scheduled Pinned Locked Moved C#
questioncsharphelp
6 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    schoetbi
    wrote on last edited by
    #1

    Hello, I have the problem that I have a lengthy c header file containing something like: typedef enum { enum1, enum2, enum3, ... a lot more } MyEnums; How can I best reuse this information in my CS projects without cut'n paste or even retype this? Thanks, Tobias

    L P M 3 Replies Last reply
    0
    • S schoetbi

      Hello, I have the problem that I have a lengthy c header file containing something like: typedef enum { enum1, enum2, enum3, ... a lot more } MyEnums; How can I best reuse this information in my CS projects without cut'n paste or even retype this? Thanks, Tobias

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      hi, two ideas: 1. write a little program to rework the source file or 2. compile as a C++/CLI dll, decompile with reflector towards C# source. (this will loose all comments, assuming you have them; not clear from your post). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        hi, two ideas: 1. write a little program to rework the source file or 2. compile as a C++/CLI dll, decompile with reflector towards C# source. (this will loose all comments, assuming you have them; not clear from your post). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


        S Offline
        S Offline
        schoetbi
        wrote on last edited by
        #3

        Thank you for your post, I allready tried the second solution, but didn't succeed. I didn't find the typedef enum in the reflected dll. Do you know how excactly I need to include the typedef? Tobias

        P 1 Reply Last reply
        0
        • S schoetbi

          Thank you for your post, I allready tried the second solution, but didn't succeed. I didn't find the typedef enum in the reflected dll. Do you know how excactly I need to include the typedef? Tobias

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          You can't. typedef is a C keyword and not C#. As Luc said, you could use C/CLI to get this. Why can you not cut/paste this code?

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          1 Reply Last reply
          0
          • S schoetbi

            Hello, I have the problem that I have a lengthy c header file containing something like: typedef enum { enum1, enum2, enum3, ... a lot more } MyEnums; How can I best reuse this information in my CS projects without cut'n paste or even retype this? Thanks, Tobias

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Hmmm.... as far as the enum is concerned; perhaps a RegEx to extract it and rewrite it in C# syntax? An interesting little project, I may have to try it.

            1 Reply Last reply
            0
            • S schoetbi

              Hello, I have the problem that I have a lengthy c header file containing something like: typedef enum { enum1, enum2, enum3, ... a lot more } MyEnums; How can I best reuse this information in my CS projects without cut'n paste or even retype this? Thanks, Tobias

              M Offline
              M Offline
              m0
              wrote on last edited by
              #6

              Usually a typedef is defined in another header, take a look at the original type of the typedef, then you can properly assign that type in C#. Any code will be useful

              Microsoft Student Partner

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups