www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bitfileds Error: no identifier for declarator

reply data pulverizer <data.pulverizer gmail.com> writes:
Hi,

I am trying to compile the following items:


```
import std.bitmanip: bitfields;

enum TYPE_BITS = 5;
enum NAMED_BITS = 16;

struct sxpinfo_struct {
   mixin(bitfields!(
     SEXPTYPE, "type", TYPE_BITS,
     uint, "scalar",   1,
     uint, "obj",      1,
     uint, "alt",      1,
     uint, "gp",      16,
     uint, "mark",     1,
     uint, "debug",    1,
     uint, "trace",    1,
     uint, "spare",    1,
     uint, "gcgen",   1,
     uint, "gccls",   3,
     uint, "named",  NAMED_BITS,
     uint, "extra",  32 - NAMED_BITS));
}
```

But I get the error:

```
Error: no identifier for declarator `uint`
Error: identifier or integer expected inside `debug(...)`, not `)`
Error: found ` ` when expecting `)`
Error: no identifier for declarator `safe`
Error: declaration expected, not `return`
Error: no identifier for declarator `void`
Error: identifier or integer expected inside `debug(...)`, not 
`uint`
Error: found `v` when expecting `)`
Error: declaration expected, not `)`
Error: declaration expected, not `assert`
Error: basic type expected, not `cast`
Error: found `cast` when expecting `;`
Error: declaration expected, not `(`
```

All referencing the `bitfields` `mixin`, more specifically the 
last two lines but I think it's actually referencing the expanded 
`mixin` rather than my declaration.

Thanks
Oct 27 2021
next sibling parent data pulverizer <data.pulverizer gmail.com> writes:
On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer 
wrote:
 Hi,

 I am trying to compile the following items ...
Sorry forgot to prepend: ``` enum SEXPTYPE { NILSXP = 0, SYMSXP = 1, LISTSXP = 2, CLOSXP = 3, ENVSXP = 4, PROMSXP = 5, LANGSXP = 6, SPECIALSXP = 7, BUILTINSXP = 8, CHARSXP = 9, LGLSXP = 10, INTSXP = 13, REALSXP = 14, CPLXSXP = 15, STRSXP = 16, DOTSXP = 17, ANYSXP = 18, VECSXP = 19, EXPRSXP = 20, BCODESXP = 21, EXTPTRSXP = 22, WEAKREFSXP = 23, RAWSXP = 24, S4SXP = 25, NEWSXP = 30, FREESXP = 31, FUNSXP = 99 } ``` In case someone is trying to replicate the error.
Oct 27 2021
prev sibling next sibling parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer 
wrote:
 Hi,

 I am trying to compile the following items:

 [...]
Try renaming debug to something else
Oct 27 2021
next sibling parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Thursday, 28 October 2021 at 05:51:27 UTC, Imperatorn wrote:
 On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer 
 wrote:
 Hi,

 I am trying to compile the following items:

 [...]
Try renaming debug to something else
uint, "debugflag", 1,
Oct 27 2021
prev sibling parent data pulverizer <data.pulverizer gmail.com> writes:
On Thursday, 28 October 2021 at 05:51:27 UTC, Imperatorn wrote:
 Try renaming debug to something else
Many thanks guys. I should have spotted that one!
Oct 27 2021
prev sibling parent Stanislav Blinov <stanislav.blinov gmail.com> writes:
On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer 
wrote:

 I am trying to compile the following items:

 struct sxpinfo_struct {
   mixin(bitfields!(
     // ...
     uint, "debug",    1,
     // ...
 }
 ```

 But I get the error...
`debug` is a language keyword, try a different one, like "debug_". That error message though, much wow.
Oct 27 2021