Skip to content

Changing type of data_ to size_t to avoid compilation errors#4200

Merged
vitaut merged 6 commits intofmtlib:masterfrom
vinayyadav3016:master
Oct 19, 2024
Merged

Changing type of data_ to size_t to avoid compilation errors#4200
vitaut merged 6 commits intofmtlib:masterfrom
vinayyadav3016:master

Conversation

@vinayyadav3016
Copy link
Copy Markdown
Contributor

  1. If lib is cross-compiled for win32 using MXE environment it cause
    compilation error -Wconversion on line 730 as sizeof(unsigned long)
    = 4 and sizeof(size_t) = 8
  2. When lib is compiled on Unix like compiler generate error
    -Wuseless-cast if static_cast is used to fix issue in 1

when FMT_PEDANTIC && FMT_WERROR options are enabled
"""
error: useless cast to type 'class fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >' [-Werror=useless-cast]
 1449 |                      basic_format_args<buffer_context<char>>(args));
"""
cross compiling for win32 application using MXE environment because
long unsigned int != size_t (aka long long unsigned int)
1. If lib is cross-compiled for win32 using MXE environment it cause
   compilation error -Wconversion on line 730 as sizeof(unsigned long)
   = 4 and sizeof(size_t) = 8
2. When lib is compiled on Unix like compiler generate error
   -Wuseless-cast if static_cast is used to fix issue in 1

Futher if size_t is not concrete type then, type data_ can be changed to
uint64_t or uint32_t because those have same sizes across all platforms
@vitaut vitaut merged commit 58c185b into fmtlib:master Oct 19, 2024
@vitaut
Copy link
Copy Markdown
Contributor

vitaut commented Oct 19, 2024

Thank you

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 this pull request may close these issues.

2 participants