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

type name first seen using 'struct' now seen using 'class' #277

Open
jlfaucher opened this issue Oct 29, 2022 · 1 comment
Open

type name first seen using 'struct' now seen using 'class' #277

jlfaucher opened this issue Oct 29, 2022 · 1 comment
Labels
B-cpp C++ backend obsolete-with-hir This issue only pertains to obsolete AST backends and can be closed when they're removed

Comments

@jlfaucher
Copy link

Using ICU4X, the Microsoft compiler reports these warnings when using the option warnings level 2 /W2:

(compiling the ICU4X C++ FFI example for locale)

cl /Zi /std:c++20 /EHsc /W3 test.cpp ..\..\..\..\..\target\debug\icu_capi_staticlib.lib userenv.lib advapi32.lib ws2_32.lib bcrypt.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
E:\Local\Unicode\ICU4X\git\ffi\diplomat\cpp\examples\locale\../../include/ICU4XLocale.hpp(14): warning C4099: 'ICU4XLocale': type name first seen using 'struct' now seen using 'class'
E:\Local\Unicode\ICU4X\git\ffi\diplomat\cpp\include\diplomat_result_box_ICU4XLocale_ICU4XError.h(9): note: see declaration of 'ICU4XLocale'
E:\Local\Unicode\ICU4X\git\ffi\diplomat\cpp\examples\locale\../../include/ICU4XLocale.hpp(32): warning C4099: 'ICU4XLocale': type name first seen using 'struct' now seen using 'class'
E:\Local\Unicode\ICU4X\git\ffi\diplomat\cpp\examples\locale\../../include/ICU4XLocale.hpp(32): note: see declaration of 'ICU4XLocale'

The warning could be avoided if the struct is declared into the namespace capi.

Example of generated code:
diplomat_result_box_ICU4XLocale_ICU4XError.h

typedef struct ICU4XLocale ICU4XLocale;
#include "ICU4XError.h"
#ifdef __cplusplus
namespace capi {
extern "C" {
#endif
    typedef struct diplomat_result_box_ICU4XLocale_ICU4XError {
    union {
        ICU4XLocale* ok;
        ICU4XError err;
    };
    bool is_ok;
} diplomat_result_box_ICU4XLocale_ICU4XError;
#ifdef __cplusplus
} // extern "C"
} // namespace capi
#endif
@Manishearth
Copy link
Contributor

Yeah, our C++ headers need a bunch of improvement, planned as a part of #280

@Manishearth Manishearth added obsolete-with-hir This issue only pertains to obsolete AST backends and can be closed when they're removed B-cpp-AST B-cpp C++ backend and removed B-cpp-AST labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-cpp C++ backend obsolete-with-hir This issue only pertains to obsolete AST backends and can be closed when they're removed
Projects
None yet
Development

No branches or pull requests

2 participants