mirror of https://github.com/swig/swig
Support binary integer literals in the preprocessor
This commit is contained in:
parent
3140acd748
commit
1bfe88eeda
|
@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-07-25: olly
|
||||
Support for C++14 binary integer literals in preprocessor expressions.
|
||||
|
||||
2022-07-20: wsfulton
|
||||
[C#, Java] Ensure the order of interfaces generated in proxy interfaces for the
|
||||
%interface family of macros is the same as that parsed from the bases in C++.
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
%module cpp14_binary_integer_literals
|
||||
|
||||
#if 0b100 < 4
|
||||
# error binary constant in preprocessor expression failed
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
int b1 = 0b1;
|
||||
int b2 = 0b10;
|
||||
|
|
|
@ -318,7 +318,12 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
|
||||
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
|
||||
char *c = Char(Scanner_text(scan));
|
||||
stack[sp].value = (long) strtol(c, 0, 0);
|
||||
if (c[0] == '0' && (c[1] == 'b' || c[1] == 'B')) {
|
||||
// strtol() doesn't handle binary constants.
|
||||
stack[sp].value = (long) strtol(c + 2, 0, 2);
|
||||
} else {
|
||||
stack[sp].value = (long) strtol(c, 0, 0);
|
||||
}
|
||||
stack[sp].svalue = 0;
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
} else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_PLUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) {
|
||||
|
|
Loading…
Reference in New Issue