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

error: operator '!' has no right operand (ONLY_C_LOCALE) #589

Closed
nschloe opened this issue Jul 16, 2020 · 6 comments · Fixed by #590
Closed

error: operator '!' has no right operand (ONLY_C_LOCALE) #589

nschloe opened this issue Jul 16, 2020 · 6 comments · Fixed by #590

Comments

@nschloe
Copy link
Contributor

nschloe commented Jul 16, 2020

I get some weird errors when trying to compile with date.h:

/usr/include/date/date.h:3783:19: error: operator '!' has no right operand
 3783 | #if !ONLY_C_LOCALE
[...]

(For full details: https://launchpadlibrarian.net/488835127/buildlog_ubuntu-focal-amd64.waybar_0.9.2-202007161902-0fe0a856-1focal1_BUILDING.txt.gz.)

Seems like the ONLY_C_LOCALE is not defined, but I see

  #ifndef ONLY_C_LOCALE
  #  define ONLY_C_LOCALE 0
  #endif

towards the top of date.h.

Any idea what might be wrong?

@HowardHinnant
Copy link
Owner

This is a bug in the build system. Search for "-DONLY_C_LOCALE= in the build log you have. This is setting ONLY_C_LOCALE to "". The header date.h expects it to be set to 0 or 1, and if not defined, defaults it to 0.

@nschloe
Copy link
Contributor Author

nschloe commented Jul 16, 2020

You're right, thanks for looking into it!

@nschloe nschloe closed this as completed Jul 16, 2020
@nschloe
Copy link
Contributor Author

nschloe commented Jul 16, 2020

Will need to reopen this. Can it be that the faulty definition comes from

target_compile_definitions( date INTERFACE
    #To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388
    ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0>
    $<$<BOOL:${DISABLE_STRING_VIEW}>:HAS_STRING_VIEW=0> )

in date's CMakeLists.txt?

@nschloe nschloe reopened this Jul 16, 2020
@HowardHinnant
Copy link
Owner

HowardHinnant commented Jul 16, 2020

Could be. I don't really know CMake and personally avoid it whenever I can. If you've got a fix for this, I'd be happy to take it. For my use cases CMake causes far more problems than it solves.

If you just need date.h, then there is no installation other than just including it.

For tz.h, here are the build instructions I recommend and use: https://howardhinnant.github.io/date/tz.html#Installation

@nschloe
Copy link
Contributor Author

nschloe commented Jul 16, 2020

I need to create a Debian build for date which includes tz.h. Doing as if there were only .c and .h will create the need for a lot of extra code that I'd rather avoid (because I don't know Debian's build system well enough).

@nschloe
Copy link
Contributor Author

nschloe commented Jul 16, 2020

Okay, in the output dateTargets.cmake, one finds

INTERFACE_COMPILE_DEFINITIONS "ONLY_C_LOCALE=\$<IF:\$<BOOL:OFF>,1,0>;\$<\$<BOOL:OFF>:HAS_STRING_VIEW=0>"

which looks really fishy. This should probably be

INTERFACE_COMPILE_DEFINITIONS "ONLY_C_LOCALE=0"

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

Successfully merging a pull request may close this issue.

2 participants