Comments (10)
I'll see what I can do about it.
from dstep.
Do you have an example of C code causing this problem?
from dstep.
Try any anonymous enum with multiple elements. For example, the following is taken from a header I was translating:
enum {
ASENSOR_TYPE_ACCELEROMETER = 1,
ASENSOR_TYPE_MAGNETIC_FIELD = 2,
ASENSOR_TYPE_GYROSCOPE = 4,
ASENSOR_TYPE_LIGHT = 5,
ASENSOR_TYPE_PROXIMITY = 8
};
It got translated to this:
extern (C):
enum _Anonymous_0
{
ASENSOR_TYPE_ACCELEROMETER = 1,
ASENSOR_TYPE_MAGNETIC_FIELD = 2,
ASENSOR_TYPE_GYROSCOPE = 4,
ASENSOR_TYPE_LIGHT = 5,
ASENSOR_TYPE_PROXIMITY = 8
}
Nobody's going to want to write _Anonymous_0.ASENSOR_TYPE_ACCEROMETER
all over their code.
from dstep.
There is some problem with translating a corner case. Consider following code:
enum {
FOO,
BAR,
} baz;
D doesn't allow such a construction, so the enum is required to have explicit name, on the other side the enum items are still visible in global space. The best thing I can think of at the moment is to declare baz
as int
.
from dstep.
The best solution would be to name the enum and still export its items to the global scope.
from dstep.
Yeah, just through an alias.
from dstep.
Could you provide an example ?
from dstep.
Do you mean to repeat all the enumeration items as the aliases in global scope?
from dstep.
enum _Anonymous_0
{
FOO,
BAR
}
alias FOO = _Anonymous_0.FOO;
alias BAR = _Anonymous_0.BAR;
from dstep.
Well, this can be done.
from dstep.
Related Issues (20)
- `--normalize-modules` insert underscore in the module decl but not in the filename
- typedef function prototypes don't retain arguments HOT 5
- dub run failure - ld cannot find @linker_flags.txt HOT 4
- doc error:
- Missing import HOT 2
- Unhandled type kind objCTypeParam HOT 2
- const T arr[] gets converted to imcompatible const(T) *arr instead of a warning HOT 2
- Improper output when importing core.stdc.limits HOT 1
- Rename enum members can create invalid enum names HOT 1
- API macro erased but should be extern(System) HOT 2
- /usr/include/cuda_runtime_api.h ==> d: Error: undefined identifier `cudaError_t` HOT 6
- Assertion Failure when defining a cast from int to function pointer
- Unhandled type kind objCObject when trying to bind Foundation.framework on macOS
- enh? add enum alias (as dpp do) HOT 1
- unknown type name 'size_t' HOT 1
- `--alias-enum-members=true` shouldn't affect global anonymous enums
- Unnecessary leading dot in alias
- Add support for adding public imports
- Missing `__u/int128` support HOT 13
- How to use dstep generate PostgreSQL & MySQL binding? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dstep.