Skip to content

Commit a170127

Browse files
committed
Can I omit unused argument names? - No, you can't. - Fine, but then you won't complain if I don't use them, right? - Oh you bet I will.
1 parent fd02e97 commit a170127

17 files changed

Lines changed: 66 additions & 29 deletions

tests/co_sim_io/c/checks.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,8 @@
1717
#include <math.h>
1818
#include <string.h>
1919

20-
/*
21-
Before the 23 standard, C and C++ handled unused arguments differently.
22-
C does not allow variable names to be omitted, but does not complain if
23-
the variable is unused. On the other hand, C++ allows variable names to
24-
be omitted, but will complain if it is not used when named.
25-
The "[[maybe_unused]]" attribute is a C23 extension, so it's not applicable
26-
here until support for earlier standards is dropped.
27-
*/
28-
#ifndef __cplusplus
29-
#define COSIMIO_MAYBE_UNUSED(variable_name) variable_name
30-
#else
31-
#define COSIMIO_MAYBE_UNUSED(variable_name)
32-
#endif
20+
21+
#define COSIMIO_UNUSED(variable_name) (void)(variable_name)
3322

3423
#define COSIMIO_CHECK_INT_EQUAL(a, b) \
3524
if (a != b) { \

tests/co_sim_io/c/info/test_info_bool.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_clear.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_copy.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info, copied_info;
2225

tests/co_sim_io/c/info/test_info_double.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_erase.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_info.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225
CoSimIO_Info sub_info;

tests/co_sim_io/c/info/test_info_int.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_multiple_vals.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
#include "../checks.h"
1717

18-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
18+
int main(int argc, const char** argv)
1919
{
20+
COSIMIO_UNUSED(argc);
21+
COSIMIO_UNUSED(argv);
22+
2023
/* declaring variables */
2124
CoSimIO_Info info;
2225

tests/co_sim_io/c/info/test_info_print.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616

1717
#include "../checks.h"
1818

19-
int main(int COSIMIO_MAYBE_UNUSED(argc), const char** COSIMIO_MAYBE_UNUSED(argv))
19+
int main(int argc, const char** argv)
2020
{
21+
COSIMIO_UNUSED(argc);
22+
COSIMIO_UNUSED(argv);
23+
2124
/* declaring variables */
2225
CoSimIO_Info info;
2326
char buffer[BUFSIZ];

0 commit comments

Comments
 (0)