Skip to content

How to use a constant defined in a different header #1873

@Rashmatash

Description

@Rashmatash

Trying to generate code for two headers:

// Header1.h
static const int MAX_NUMBER = 37;

And

//Header2.h
#include "Header1.h"
static const int someNumber = MAX_NUMBER;

The generated code is

public unsafe partial class Header1
{
  // ... internal stuff
   public const int MAX_NUMBER = 37;
}

public unsafe partial class Header2
{
 // ... internal stuff
   public const int someNumber = MAX_NUMBER; // compile error. Should be Header1.MaxNumber, obviously.
}

How does one go about solving this issue?

Also is it possible to tell CppSharp to only generate data declarations without all the interop/internal code? I just want to convert POD structs and enums from C/C++ to their equivalent in C#.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions