Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update C keywords #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Smattr
Copy link

@Smattr Smattr commented Jul 3, 2024

_ at the beginning of an RDL identifier seems legal, so seems we need to avoid collisions with the _-prefixed keywords as well.

@amykyta3
Copy link
Member

amykyta3 commented Jan 3, 2025

Not sure I understand the situation you describe. Can you provide a more clear example where this becomes an issue?

@Smattr
Copy link
Author

Smattr commented Jan 5, 2025

Something like this:

$ cat foo.rdl
addrmap foo {
  reg {
    name = "bar";
    field {
      hw=rw;
    } baz[1:0] = 0;
  } _Bool @ 0x0;
};
$ python3 -m peakrdl c-header foo.rdl -o header.h
$ echo $?
0
$ cat main.c
#include "header.h"
int main(void) {
  return 0;
}
$ gcc -std=c99 main.c
In file included from main.c:1:
header.h:22:14: error: two or more data types in declaration specifiers
   22 |     uint32_t _Bool;
      |              ^~~~~
header.h:22:19: warning: declaration does not declare anything
   22 |     uint32_t _Bool;
      |                   ^
header.h:26:15: error: expected declaration specifiers or ‘...’ before ‘sizeof’
   26 | static_assert(sizeof(foo_t) == 0x4, "Packing error");
      |               ^~~~~~
header.h:26:37: error: expected declaration specifiers or ‘...’ before string constant
   26 | static_assert(sizeof(foo_t) == 0x4, "Packing error");
      |                                     ^~~~~~~~~~~~~~~

This is a bit contrived, but I believe this should work right? I would expect arbitrary user RDL to be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants