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

typedef byte compatibility issue #282

Open
truposky opened this issue Nov 30, 2023 · 1 comment
Open

typedef byte compatibility issue #282

truposky opened this issue Nov 30, 2023 · 1 comment

Comments

@truposky
Copy link

Hello I am using this compiler with a c++ proyect and I am having compatibility problems. The problem is that the byte definition is done in std. This is the fail:
/usr/include/c++/9/cstddef:69:14: note: candidates are: ‘enum class std::byte’
69 | enum class byte : unsigned char {};

I solve it by changing the definitions of some files, I change the name of the byte definition to asn_byte. The files are:

  • asn1crt.h:

    line 75 : uint8_t byte;
    line 129: byte *buf
    line 147: byte *buf
    line 181: int GetCharIndex(char ch, byte allowedCharSet[], int setLen);

  • LangGeneric_c.fs:

    **line 295:**GenericLocalVariable {GenericLocalVariable.name = "arr"; varType = "byte"; arrSize = Some sReqBytesForUperEncoding; isStatic = true; initExp = None}

  • Header_c.stg

    line 161: byte arr[];
    line 184: byte arr[];

I guess this asn compiler is not intended for c++ but I hope you can make it compatible as well.

@usr3-1415
Copy link
Collaborator

Hello,

Thank you for bringing this compatibility issue to our attention and for suggesting a solution. I understand your approach of changing the byte definition to asn1_byte, but implementing this change in the asn1scc could potentially break the code for other users who rely on the current definition.

As an alternative, could you try manually modifying the definition of byte in the asn1crt.h file in your project as follows?

#ifdef __cplusplus
#include <cstddef>
using byte = std::byte;
#else
typedef uint8_t byte;
#endif

This change uses a C++-specific approach to redefine byte as an alias for std::byte only when compiling as C++, while keeping it as uint8_t for C. This way, we can maintain compatibility with existing C code.

If this solution works for you without causing any issues, it would be great if you could make a pull request with this change. This contribution could be very valuable for other users facing similar compatibility challenges in C++ environments.

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

No branches or pull requests

2 participants