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

  • SEARCH
  • Home
  • 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 856097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:11:09+00:00 2026-05-15T08:11:09+00:00

I’m writing a NON-GUI app which I want to be cross platform between OS

  • 0

I’m writing a NON-GUI app which I want to be cross platform between OS X and Windows. I’m looking at the following architecture, but I don’t know if it will work on the windows side:

(Platform specific entry point) -> ANSI C main loop => ANSI C model code doing data processing / logic => (Platform specific helpers)

So the core stuff I’m planning to write in regular ANSI C, because A) it should be platform independent, B) I’m extremely comfortable with C, C) It can do the job and do it well

(Platform specific entry point) can be written in whatever necessary to get the job done, this is a small amount of code, doesn’t matter to me.

(Platform specific helpers) is the sticky thing. This is stuff like parsing XML, accessing databases, graphics toolkit stuff, whatever. Things that aren’t easy in C. Things that modern languages/frameworks will give for free. On OS X this code will be written in Objective-C interfacing with Cocoa. On Windows I’m thinking my best bet is to use C#

So on Windows my architecture (simplified) looks like

(C# or C?) -> ANSI C -> C#

Is this possible? Some thoughts/suggestions so far..

1) Compile my C core as a .dll — this is fine, but seems there’s no way to call my C# helpers unless I can somehow get function pointers and pass them to my core, but that seems unlikely

2) Compile a C .exe and a C# .exe and have them talk via shared memory or some kind of IPC. I’m not entirely opposed to this but it obviously introduces a lot of complexity so it doesn’t seem ideal

3) Instead of C# use C++, it gets me some nice data management stuff and nice helper code. And I can mix it pretty easily. And the work I do could probably easily port to Linux. But I really don’t like C++, and I don’t want this to turn in to a 3rd-party-library-fest. Not that it’s a huge deal, but it’s 2010.. anything for basic data management should be built in. And targetting Linux is really not a priority.

Note that no “total” alternatives are OK as suggested in other similar questions on SO I’ve seen; java, RealBasic, mono.. this is an extremely performance intensive application doing soft realtime for game/simulation purposes, I need C & friends here to do it right (maybe you don’t, but I do)

  • 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-05-15T08:11:09+00:00Added an answer on May 15, 2026 at 8:11 am

    First of all, to answer one specific worry: you can marshal delegates as function pointers to your native C code – in fact, it “just works”, and P/Invoke will take care of all the wrapping:

    // C#
    class ManagedEntryPoint {
    
        [DllImport("core", CallingConvention=CallingConvention.Cdecl)]
        static extern void NativeEntryPoint(Func<int, int, float> helper);
    
        static float Helper(int, int) { ... }
    
        static void Main() {
            NativeEntryPoint(Helper);
        }
    }
    
    // C
    void NativeEntryPoint(float (*helper)(int, int)) {
        float x = helper(1, 2);
        ...
    }
    

    However, I don’t see much point in this – it’s easier to use C++/CLI compiler. Note that this doesn’t mean that you actually have to use C++ – you can stick to the subset of C which is C++-compatible, which is 95% of it (I’d expect about the only thing you’ll need to do differently in practice is explicitly casting the return of malloc). You compile your native C functions as a native .lib, and then link that to an executable compiled with /clr. C++/CLI will take care of all the marshaling itself, and you won’t need to write P/Invoke declarations and such.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported

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.