Skip to content

Doesn't run in C #7

@racoltdev

Description

@racoltdev

Primary issue with porting to C is use of try/catch. Resolution strategies:

  1. Emulate try/catch with setjmp/longjmp

try/catch does 3 important things:

  1. It opens an exception safe code block
  2. It produces a stack trace
  3. It produces named, detailed exception messages

Producing all of these in C is difficult.

  1. Can be done with a fork() or setjmp/longjmp. Both are equally as expensive (I think. I need to research this). fork() is not posix or windows compliant. There is no equivalent command that works on both posix and windows, but there are commands that work on each. Different implementations would be required for each target. setjmp/longjmp is posix and windows compliant. Any goto in between setjmp and longjmp will leak memory, so caution must be taken.
  2. Can be accomplished with glibc execinfo.h backtrace(). A rough equivalent exists on windows, but requires multiple libraries and an executable to be installed: no. A cross platform library targetting linux, bsd, and windows exists called libbacktrace
  3. The best C can do regarding this is print what signal killed it. No C compatable function can interface naturally with the cpp exception system. A compilation switch between these two systems will be necessary to maintain the full use of cpp exceptions.

Use of classes and namespaces must be removed as well, but use of these is limited anyways and won't require complex restructuring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    High EffortMore than 2 weeks of timeHigh priorityMultiple features rely on this, it is a milestone, or issue strongly effects end usersenhancementImprove or add new featurestodoPlanned implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions