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

compiler error ( from warning) when compiled with FOONATHAN_MEMORY_DEBUG_ASSERT and FOONATHAN_MEMORY_ASSERT not defined #183

Open
felixf4xu opened this issue May 28, 2024 · 1 comment · May be fixed by #184

Comments

@felixf4xu
Copy link

felixf4xu commented May 28, 2024

Hi,

When compiled with the default settings, neither FOONATHAN_MEMORY_DEBUG_ASSERT or FOONATHAN_MEMORY_ASSERT is defined.

so this line

#define FOONATHAN_MEMORY_ASSERT_MSG(Expr, Msg)

will be evaluated to empty code and then

auto result = VirtualFree(pages, 0u, MEM_RELEASE);
FOONATHAN_MEMORY_ASSERT_MSG(result, "cannot release pages");

will have a compiling error (originally warning):

src/foo_mem-ext/src/virtual_memory.cpp: In function 'void foonathan::memory::virtual_memory_release(void*, std::size_t)':
src/foo_mem-ext/src/virtual_memory.cpp:50:10: error: unused variable 'result' [-Werror=unused-variable]
50 | auto result = VirtualFree(pages, 0u, MEM_RELEASE);
| ^~~~~~

@felixf4xu felixf4xu changed the title compiler error ( from warning) when compiled with FOONATHAN_MEMORY_ASSERT and FOONATHAN_MEMORY_ASSERT not defined compiler error ( from warning) when compiled with FOONATHAN_MEMORY_DEBUG_ASSERT and FOONATHAN_MEMORY_ASSERT not defined May 28, 2024
@felixf4xu
Copy link
Author

my current workaround is to change the line to

#define FOONATHAN_MEMORY_ASSERT_MSG(Expr, Msg) (void)(Expr)

not sure if it's a perfect solution.

@felixf4xu felixf4xu linked a pull request Jun 12, 2024 that will close this issue
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 a pull request may close this issue.

1 participant