-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The generic min macro in util.h is too common and can conflict with other libraries. use ccan/minmax in the source files to avoid pollution. the ccan/minmax will check the type of the input parameters, so cast the `u8* - u8*` to `int` to avoid the type mismatch. Before renaming the macro, the cpp's std::min will fail to compile. ``` ./test/cpp.cc: In function ‘int min_compile_test()’: ../src/nvme/util.h:563:19: error: expected unqualified-id before ‘(’ token 563 | #define min(x, y) ((x) > (y) ? (y) : (x)) ``` Signed-off-by: Jian Zhang <[email protected]>
- Loading branch information
1 parent
e9c6fe6
commit 9d3a939
Showing
5 changed files
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,15 @@ | |
* Authors: Keith Busch <[email protected]> | ||
*/ | ||
|
||
#include <algorithm> | ||
#include <iostream> | ||
#include <libnvme.h> | ||
|
||
static int min_compile_test() | ||
{ | ||
return std::min(1, 2); | ||
} | ||
|
||
int main() | ||
{ | ||
nvme_root_t r; | ||
|
@@ -62,5 +68,7 @@ int main() | |
std::cout << "\n"; | ||
nvme_free_tree(r); | ||
|
||
min_compile_test(); | ||
|
||
return 0; | ||
} |