Skip to content

Added support for c++ #59

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

lmarzocchetti
Copy link

Hi tsoding, i love this project and i would love to use it with c++. I have modified nob.h (and a test) to compile with g++ and clang++. I have run the nob with c and c++ with my modified version and both works! The only "meh", is that with c++ you have a lot of warnings in the tests (because of some differences between c and c++) but all works as expected i think

Comment on lines +1587 to +1592
size_t new_count;
#ifndef _WIN32
long m;
#else
long long m;
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you separate declaration and initialization? does c++ not work without it?

Comment on lines +12 to +15
const char *message;
const char *message_file_path;
Proc p;
String_View actual_message;
Copy link
Contributor

Choose a reason for hiding this comment

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

same question here

Copy link
Author

@lmarzocchetti lmarzocchetti Apr 28, 2025

Choose a reason for hiding this comment

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

Because the preprocessor (and goto) rules in C++ are strictier than the C. The usage of "return_defer" macro must be after all declaration. So you cannot jump with goto after a declaration+initialization of a variable. So i simply separated them and all works as expected

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.

3 participants