emscripten-core / emscripten-core/emscripten

cmake: CheckTypeSize does not work correctly for types > 255?

Open
#18,238 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

The custom shipped CheckTypeSize module does not handle types greater than 255 bytes correctly.

**Version of emscripten/emsdk:**
3.1.23

**Testing source**
```
cmake_minimum_required(VERSION 3.10)

project(sizeof-test)

include(CheckTypeSize)

check_type_size("char[15]" size1)
check_type_size("char[2048]" size2)
check_type_size("char[2049]" size3)
check_type_size("char[2047]" size4)

message(WARNING "${size1} ${size2} ${size3} ${size4}") # 15 0 1 255

```

```
-- Check size of char[15]
-- Check size of char[15] - done
-- Check size of char[2048]
-- Check size of char[2048] - done
-- Check size of char[2049]
-- Check size of char[2049] - done
-- Check size of char[2047]
-- Check size of char[2047] - done
CMake Warning at CMakeLists.txt:63 (message):
15 0 1 255
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.