dotnet / dotnet/ClangSharp

A value-like macro binding that isn't constant should not be a static readonly field, it should be a static readonly property

Open
#833 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.3k
Forks
187
Avg merge
6d 19h
Merged PRs (30d)
1

Description

This macro ([source](https://github.com/erincatto/box3d/blob/23861418d877fdd97990f35645e845e44a7eb9ec/include/box3d/constants.h#L27))
```c
#define B3_HUGE ( 1.0e9f * b3GetLengthUnitsPerMeter() )
```
generates
```cs
[NativeTypeName("#define B3_HUGE ( 1.0e5f * b3GetLengthUnitsPerMeter() )")]
public static readonly float B3_HUGE = (1.0e5f * b3GetLengthUnitsPerMeter());
```
but `b3GetLengthUnitsPerMeter()` can change during runtime.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with include/box3d/constants.h at the B3_HUGE definition and trace how ClangSharp generates the shown C# binding for value-like macros. Verify the generated member reflects changes from b3GetLengthUnitsPerMeter() at runtime; done means the binding is a static readonly property rather than an eagerly initialized field.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.