Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:51:22+00:00 2026-06-17T20:51:22+00:00

I have a auto-generated .c file containing const’s and enum’s I need to access

  • 0

I have a auto-generated .c file containing const’s and enum’s I need to access from .Net. I would like to run a pre-build script that would convert the .c file (with C syntax) to a .cs file (with C# syntax). The files are pretty simple so it should be possible to script my way out of this problem.

Here is a section of a .c file

#define Bitfile "Test.bit"

static const char* const BitfileSignature = "A6A316954DA417A2F886F3B0035019B1";

typedef enum
{
   ControlBool_TestBool_Address = 0x815E,
   ControlBool_IrqHandshakeWriteToDma_Address = 0x8112,
   ControlBool_WriteToDma_Address = 0x810E,
   ControlBool_stop_Address = 0x813A,
} ControlBool;

And I would like to convert that into something like this

public static class MyConstants
{
    public static string Bitfile = "Test.bit";
    public static string BitfileSignature = "A6A316954DA417A2F886F3B0035019B1";
}

public enum MyEnum
{
    ControlBool_TestBool_Address = 0x815E,
    ControlBool_IrqHandshakeWriteToDma_Address = 0x8112,
    ControlBool_WriteToDma_Address = 0x810E,
    ControlBool_stop_Address = 0x813A,
}

Does anyone know a good tool I could use for this conversion? Preferably a tool that comes with VS2010.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:51:24+00:00Added an answer on June 17, 2026 at 8:51 pm

    You can try T4 Text Templates to generate your code files from. It’s nicely integrated into Visual Studio and once you get the hang of it a fairly easy to use and powerful text templating engine. You’ll need to define 2 separate templates (one for C# and one for C) of course.

    [EDIT] : It appears i did not read the whole question. The OP problem is converting from C to C#. I still stand by my advice to use T4 in this case but for reading the C source you’ll need to write some custom parsing code. Considering that it involves only enum type definitions the parsing code should be fairly trivial. On the other hand if the C defs are already generated from some external definition (like an xml file somewhere) then you could treat that as a data source

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an auto-generated file which looks something like this... static void do_SomeFunc1(void* parameter)
I have an auto-generated XML file which I have to fill with values from
I have a .dbml file which of course contains the auto-generated classes based on
I have a very large file that creates triggers that I auto generated. However
I have an auto-generated file each day that gets called by a shell script.
i have to display auto-generated images from a folder in html. how can i
I have a property auto-generated from database in my edmx: Description . I then
I have an autogenerated class from importing a web service containing something like this
In our ASP.NET MVC project we have a Strings.resx file and the accompanying autogenerated
I have some auto-generated HTML code. When I add a float:left; on the shared

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.