Skip to content

[25748] Option to leave out wide characters and strings - #352

Merged
richiware merged 6 commits into
masterfrom
feature/fastcdr-face-wstrings
Nov 23, 2026
Merged

richiware merged 6 commits into
masterfrom
feature/fastcdr-face-wstrings

Conversation

@emiliocuestaf

@emiliocuestaf emiliocuestaf commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

A new CMake option, FASTCDR_DISABLE_WSTRINGS (default OFF, defined to 0 or 1 in config.h), leaves the wide characters and strings out of the API, for standard libraries that do not provide them: every wchar_t and std::wstring overload of Cdr, FastCdr and CdrSizeCalculator, and their definitions.

With the option OFF nothing changes. With it ON, the tests that use wide types are left out. The complete tests now serialize the wide types in a block of their own after the rest (the string sequence moved before them), in both modes.

A new CI job builds and tests with the option on: 1948 tests pass with it, and 2124 without it.

The FACE check job added by #351 now configures Fast CDR with FASTCDR_DISABLE_WSTRINGS=ON: the C++11 General Purpose capability set excludes wide characters and strings, so that is the configuration a FACE application uses, and the check passes with it.

This PR depends on #351 and must be merged after that one.

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • New feature has been added to the versions.md file (if applicable).
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: CI pass and failing tests are unrelated with the changes.

@MiguelCompany MiguelCompany added this to the v2.5.0 milestone Oct 28, 2026
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from 7109d2f to 89e6bf8 Compare October 30, 2026 16:01
@emiliocuestaf
emiliocuestaf added this pull request to stack #353 October 30, 2026 16:01
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from 89e6bf8 to 16b1144 Compare October 30, 2026 17:21
emiliocuestaf added a commit that referenced this pull request Nov 3, 2026
utils/face/check_face.py compiles Fast CDR as the FACE Conformance Test Suite compiles a Unit of Conformance: each
public header alone and each source, with the compiler flags of the CTS toolchain and only the gold standard headers
of the profile. Then the functions the objects use must be defined by the gold standard libraries, built from their
CTS sources, the default allowed definitions of the CTS, or allowed_symbols.txt (the C++ exception runtime). It lists
every issue where it is, with the files that run into it, and fails when there is any.

Only the gold standard files are fetched from the CTS 3.2.3 archive, with HTTP range requests (10 MB), and checked
against their SHA-256. FASTCDR_FACE_TEST (GCC on Linux, OFF by default, since it needs network access) adds it as the
CTest test FaceGeneralPurpose, which the Ubuntu CI runs.

It fails until wide strings can be left out (#352): the profile excludes them.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch 2 times, most recently from fe705de to a0bbed1 Compare November 3, 2026 18:08
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from a0bbed1 to 47a03e7 Compare November 5, 2026 15:57
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from 47a03e7 to 36334eb Compare November 13, 2026 12:13
Base automatically changed from feature/fastcdr-face-portability-fixes to master November 18, 2026 07:02
emiliocuestaf added a commit that referenced this pull request Nov 18, 2026
* Portability fixes for restricted standard libraries

Every header now includes what it uses, and the C library names are written as C++ declares them: <cstdint>,
<cstring>, <cstdlib>... and std::uint32_t, std::size_t, std::memcpy... Each form is only guaranteed by its own
header, so code mixing them (<cstdint> with uint32_t) only builds with standard libraries that declare both, as
GNU's does. <malloc.h>, which is not standard, is replaced by <cstdlib>.

The C headers in config.h are for the code generated by Fast DDS Gen, which uses the C names without std::.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* Standard C++ instead of memccpy, and <atomic> only where it is used

fixed_string copies with a bounded loop and std::memcpy instead of memccpy (_memccpy on Windows), which is POSIX
and not standard C++, with the same result: the terminator is copied when it fits. The MEMCCPY macro is removed.

memory_helpers.hpp includes <atomic> only for MSVC, the only compiler whose clobber_memory() uses it, so that the
other compilers do not need the header.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* Keep the MEMCCPY macro, defined as a standard C++ memccpy

MEMCCPY is defined by a public header, so code that includes Fast CDR may use it. It is kept, and now names
eprosima::fastcdr::detail::memccpy, a standard C++ copy with memccpy's semantics, instead of POSIX's memccpy
(_memccpy on Windows), which is not standard C++. fixed_string::set uses it again.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* Uncrustify

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* No C headers in config.h

config.h included <stddef.h>, <stdint.h> and <string.h> for the code generated by Fast DDS Gen, which used size_t,
uint32_t and memcpy without std::. The generated code now includes what it uses and writes the std:: names
(eProsima/Fast-DDS-Gen-Pro#49), and config.h uses none of them, so they are removed.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

* FACE check of the C++11 General Purpose capability set

utils/face/check_face.py compiles Fast CDR as the FACE Conformance Test Suite compiles a Unit of Conformance: each
public header alone and each source, with the compiler flags of the CTS toolchain and only the gold standard headers
of the profile. Then the functions the objects use must be defined by the gold standard libraries, built from their
CTS sources, the default allowed definitions of the CTS, or allowed_symbols.txt (the C++ exception runtime). It lists
every issue where it is, with the files that run into it, and fails when there is any.

Only the gold standard files are fetched from the CTS 3.2.3 archive, with HTTP range requests (10 MB), and checked
against their SHA-256. It runs in a job of the Ubuntu CI of its own, independent of the build and test matrix: it only
needs the configured sources (for config.h). The job runs utils/face/check_face.py directly, which is also how it runs
by hand.

It fails until wide strings can be left out (#352): the profile excludes them.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>

---------

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from 2515efc to 030247f Compare November 18, 2026 07:02
FASTCDR_DISABLE_WSTRINGS (CMake option, defined in config.h) leaves wchar_t and std::wstring out of the API of Cdr,
FastCdr and CdrSizeCalculator, for standard libraries that do not provide them. The tests that use them are left out
with it, and the complete tests serialize the wide types in a block of their own. A CI job builds and tests with the
option on.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
The FACE CI job configures Fast CDR with FASTCDR_DISABLE_WSTRINGS: the C++11 General Purpose capability set excludes
wide characters and strings, so that is the configuration a FACE application uses.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from 030247f to af27d96 Compare November 19, 2026 06:35
@emiliocuestaf
emiliocuestaf requested review from richiware and removed request for richiware November 19, 2026 06:35
Comment thread CMakeLists.txt Resolved
richiware
richiware previously approved these changes Nov 19, 2026
The maximum deserialization depth used uint32_t from the global namespace, which <cstdint> is not required to declare,
and the FACE check failed on it.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
With FASTCDR_DISABLE_WSTRINGS, a test poisons wchar_t and wstring after the standard headers and before the Fast CDR
ones, so it fails to compile if a wide overload is added without the guard. GCC and Clang only.

Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
@emiliocuestaf
emiliocuestaf force-pushed the feature/fastcdr-face-wstrings branch from a638224 to f0ec4d6 Compare November 23, 2026 09:51
@richiware
richiware merged commit d932e50 into master Nov 23, 2026
@richiware
richiware deleted the feature/fastcdr-face-wstrings branch November 23, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants