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 in .h shadows class in .hpp #393

Closed
robertbastian opened this issue Dec 19, 2023 · 0 comments · Fixed by #394
Closed

Typedef in .h shadows class in .hpp #393

robertbastian opened this issue Dec 19, 2023 · 0 comments · Fixed by #394
Labels
bug Something isn't working

Comments

@robertbastian
Copy link
Collaborator

robertbastian commented Dec 19, 2023

In Google C++, each type's header needs to be explicitly included. This leads to an issue with Diplomat's current output. For example:

#ifndef diplomat_result_box_ICU4XBidi_ICU4XError_H
#define diplomat_result_box_ICU4XBidi_ICU4XError_H
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "diplomat_runtime.h"

typedef struct ICU4XBidi ICU4XBidi;
#include "ICU4XError.h"
#ifdef __cplusplus
namespace capi {
extern "C" {
#endif
typedef struct diplomat_result_box_ICU4XBidi_ICU4XError {
    union {
        ICU4XBidi* ok;
        ICU4XError err;
    };
    bool is_ok;
} diplomat_result_box_ICU4XBidi_ICU4XError;
#ifdef __cplusplus
} // extern "C"
} // namespace capi
#endif
#endif

Note that the typedef struct ICU4XBidi ICU4XBidi; is defined outside the namespace capi. Wherever this file is included, there is some weird shadowing going on, and our linter insists on importing this file, which then breaks everything as the struct is not a class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant