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

[Bug] C++ compiling on ESP32 gives issue in atomic #353

Closed
vortex314 opened this issue Feb 24, 2024 · 1 comment
Closed

[Bug] C++ compiling on ESP32 gives issue in atomic #353

vortex314 opened this issue Feb 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@vortex314
Copy link
Contributor

vortex314 commented Feb 24, 2024

Describe the bug

I got a compiler error on the below lines until I made the int to unsigned int cast. in refcount.h

lib/zenoh-pico/include/zenoh-pico/collections/refcount.h:48:101: note:   mismatched types '_Tp*' and 'unsigned int'
 #define _ZP_RC_OP_DECR_AND_CMP _z_atomic_fetch_sub_explicit(&p->in->_cnt, 1, _z_memory_order_release) > 1
           

The number 1 is seen as a signed int, with an atomic operation to an unsigned int

#define _ZP_RC_OP_INIT_CNT _z_atomic_store_explicit(&p.in->_cnt, 1, _z_memory_order_relaxed);
#define _ZP_RC_OP_INCR_CNT _z_atomic_fetch_add_explicit(&p->in->_cnt, 1, _z_memory_order_relaxed);
#define _ZP_RC_OP_DECR_AND_CMP _z_atomic_fetch_sub_explicit(&p->in->_cnt, 1, _z_memory_order_release) > 1

changed to

#define _ZP_RC_OP_INIT_CNT _z_atomic_store_explicit(&p.in->_cnt, (unsigned int)1, _z_memory_order_relaxed);
#define _ZP_RC_OP_INCR_CNT _z_atomic_fetch_add_explicit(&p->in->_cnt,(unsigned int) 1, _z_memory_order_relaxed);
#define _ZP_RC_OP_DECR_AND_CMP _z_atomic_fetch_sub_explicit(&p->in->_cnt, (unsigned int)1, _z_memory_order_release) > 1

To reproduce

  • compiler issue

System info

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = espidf
lib_deps = zenoh-pico
build_flags=
-DZENOH_DEBUG=0
-DZENOH_COMPILER_GCC=1
-DZ_FEATURE_LINK_SERIAL=1
-DZ_FEATURE_MULTI_THREAD=1
-DZ_FEATURE_MULTICAST_TRANSPORT=0
-DZ_FEATURE_LINK_UDP_UNICAST=0
-DZ_FEATURE_SCOUTING_UDP=0
-DZ_FEATURE_LINK_TCP=0
-DZ_FEATURE_DYNAMIC_MEMORY_ALLOCATION=1

@jean-roland
Copy link
Contributor

Solved in #382

@Mallets Mallets closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants