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

fix: include cstdio to solve stderr not declared #46

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

mesaglio
Copy link
Contributor

@mesaglio mesaglio commented Apr 8, 2024

If you make pip installation with a gcc 13 program, the compilation crash.

cpp_faster_fifo/cpp_lib/faster_fifo.cpp: In member function 'void Queue::circular_buffer_write(uint8_t*, const uint8_t*, size_t)':
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: error: 'stderr' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:58:9: note: in expansion of macro 'LOG_ASSERT'
   58 |         LOG_ASSERT(size <= max_size_bytes, "Combined message size exceeds the size of the queue");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:9:1: note: 'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
    8 | #include "faster_fifo.hpp"
  +++ |+#include <cstdio>
    9 |
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:9: error: 'fprintf' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |         ^~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:58:9: note: in expansion of macro 'LOG_ASSERT'
   58 |         LOG_ASSERT(size <= max_size_bytes, "Combined message size exceeds the size of the queue");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: error: 'stderr' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:59:9: note: in expansion of macro 'LOG_ASSERT'
   59 |         LOG_ASSERT(tail < max_size_bytes, "Tail pointer points past the buffer boundary");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: note: 'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:59:9: note: in expansion of macro 'LOG_ASSERT'
   59 |         LOG_ASSERT(tail < max_size_bytes, "Tail pointer points past the buffer boundary");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:9: error: 'fprintf' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |         ^~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:59:9: note: in expansion of macro 'LOG_ASSERT'
   59 |         LOG_ASSERT(tail < max_size_bytes, "Tail pointer points past the buffer boundary");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp: In member function 'void Queue::circular_buffer_read(uint8_t*, uint8_t*, size_t, bool)':
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: error: 'stderr' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:78:9: note: in expansion of macro 'LOG_ASSERT'
   78 |         LOG_ASSERT(new_head < max_size_bytes, "Circular buffer head pointer is incorrect");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: note: 'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:78:9: note: in expansion of macro 'LOG_ASSERT'
   78 |         LOG_ASSERT(new_head < max_size_bytes, "Circular buffer head pointer is incorrect");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:9: error: 'fprintf' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |         ^~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:78:9: note: in expansion of macro 'LOG_ASSERT'
   78 |         LOG_ASSERT(new_head < max_size_bytes, "Circular buffer head pointer is incorrect");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: error: 'stderr' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:79:9: note: in expansion of macro 'LOG_ASSERT'
   79 |         LOG_ASSERT(new_size >= 0 && new_size < max_size_bytes, "New size is incorrect after reading from buffer");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: note: 'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:79:9: note: in expansion of macro 'LOG_ASSERT'
   79 |         LOG_ASSERT(new_size >= 0 && new_size < max_size_bytes, "New size is incorrect after reading from buffer");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:9: error: 'fprintf' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |         ^~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:79:9: note: in expansion of macro 'LOG_ASSERT'
   79 |         LOG_ASSERT(new_size >= 0 && new_size < max_size_bytes, "New size is incorrect after reading from buffer");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp: In function 'int queue_get(void*, void*, void*, size_t, size_t, size_t, size_t*, size_t*, size_t*, int, float)':
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: error: 'stderr' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:239:9: note: in expansion of macro 'LOG_ASSERT'
  239 |         LOG_ASSERT(q->size >= sizeof(msg_size) + msg_size, "Queue size is less than message size!");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:17: note: 'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |                 ^~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:239:9: note: in expansion of macro 'LOG_ASSERT'
  239 |         LOG_ASSERT(q->size >= sizeof(msg_size) + msg_size, "Queue size is less than message size!");
      |         ^~~~~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:14:9: error: 'fprintf' was not declared in this scope
   14 |         fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, (msg)); \
      |         ^~~~~~~
cpp_faster_fifo/cpp_lib/faster_fifo.cpp:239:9: note: in expansion of macro 'LOG_ASSERT'
  239 |         LOG_ASSERT(q->size >= sizeof(msg_size) + msg_size, "Queue size is less than message size!");
      |         ^~~~~~~~~~
error: command '/usr/bin/aarch64-unknown-linux-gnu-gcc' failed with exit code 1

To solve this, you need to include cstdio in faster_fifo.cpp

#include <mutex>
#include <cassert>
#include <cstring>
#include <cstdio>

#include <pthread.h>
...

Copy link
Owner

@alex-petrenko alex-petrenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

@alex-petrenko alex-petrenko merged commit 691ee7e into alex-petrenko:master Apr 8, 2024
6 checks passed
@mesaglio mesaglio deleted the fix/include_cstdio branch April 9, 2024 00:03
@mesaglio
Copy link
Contributor Author

mesaglio commented Apr 9, 2024

Can this trigger a new tag?

@alex-petrenko
Copy link
Owner

I do pip releases manually. I'll trigger one in the next few days

would something like this work in the meantime? pip install git+https://github.com/alex-petrenko/faster-fifo.git

@mesaglio
Copy link
Contributor Author

mesaglio commented Apr 9, 2024

Yes thats works!

@alex-petrenko
Copy link
Owner

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