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

rime_api.h: error: RimeRegisterModule violates the C++ One Definition Rule [-Werror=odr] #954

Open
liangyongxiang opened this issue Nov 24, 2024 · 0 comments
Labels

Comments

@liangyongxiang
Copy link

Describe the bug
Type mismatch error encountered when compiling with lto turned on:

/var/tmp/portage/app-i18n/librime-1.12.0/work/librime-1.12.0/src/rime_api.h:249:15: error: ‘RimeRegisterModule’ violate
s the C++ One Definition Rule [-Werror=odr]
  249 | RIME_API Bool RimeRegisterModule(RimeModule* module);
      |               ^
/var/tmp/portage/app-i18n/librime-1.12.0/work/librime-1.12.0/src/rime_api.cc:37:15: note: return value type mismatch
   37 | RIME_API Bool RimeRegisterModule(RimeModule* module) {
      |               ^
/var/tmp/portage/app-i18n/librime-1.12.0/work/librime-1.12.0/src/rime_api.cc:37:15: note: type ‘int’ should match type ‘bool’
/var/tmp/portage/app-i18n/librime-1.12.0/work/librime-1.12.0/src/rime_api.cc:37:15: note: ‘RimeRegisterModule’ was previously declared here
/var/tmp/portage/app-i18n/librime-1.12.0/work/librime-1.12.0/src/rime_api.cc:37:15: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status

There are multiple definitions of Bool in the code:

src/rime_api.h
42:#define Bool int

src/rime_api_stdbool.h
14:#define Bool bool

To Reproduce
Steps to reproduce the bug:

export CFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
export CXXFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"

make

Expected behavior
Support to enable LTO compilation

Package:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant