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

add 'const' keyword to generated constants #54

Merged
merged 2 commits into from
Apr 23, 2023

Conversation

cbrune
Copy link

@cbrune cbrune commented Oct 14, 2022

This patch adds the const keyword to constant definitions generated by the compiler. Previously the compiler generated constants like this:

foo.h

  extern int foo;

foo.c

  int foo = 5;

With this patch, the generated code looks like:

foo.h

  extern const int foo;

foo.c

  const int foo = 5;

This patch adds the 'const' keyword to constant definitions generated
by the compiler.  Previously the compiler generated constants like
this:

  foo.h
  ======

  extern int foo;

  foo.c
  ======

  int foo = 5;

With this patch, the generated code looks like:

  foo.h
  ======

  extern const int foo;

  foo.c
  ======

  const int foo = 5;

Signed-off-by: Curt Brune <curt@enfabrica.net>
When working with integer constants, it is convenient to use #define
macros for the constants, as opposed to a variable of constant type.

This patch adds a '#define CONSTANT (value)' definition to the
generated header files.  The name of the constant is in
SCREAMING_SNAKE_CASE, converted from the regular camelCase.

Signed-off-by: Curt Brune <curt@enfabrica.net>
@eqvinox eqvinox merged commit 4109705 into opensourcerouting:master Apr 23, 2023
eqvinox added a commit that referenced this pull request Apr 23, 2023
This reverts commit 4109705, reversing
changes made to 5c4e497.
@eqvinox
Copy link

eqvinox commented Apr 23, 2023

Broke the build, reverted

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