Skip to content

Commit

Permalink
unit-test-client: fix compilation on compilers not supporting c99 mode
Browse files Browse the repository at this point in the history
This fixes the message
"error: 'for' loop initial declarations are only allowed in C99 mode",
spotted during cross-compiling of libmodbus.

The compiler (gcc) actually does support -std=c99 but it gets not
enabled by default. So a solution would be to enforce c99 mode
via CFLAGS, but this will knock out all compilers which do not
support this mode.
Moving the declaration out of the loop initialisation, seems to be
the simpler solution.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
  • Loading branch information
mhei committed Sep 26, 2014
1 parent 11459f2 commit 6d9b069
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/unit-test-client.c
Expand Up @@ -744,8 +744,9 @@ int send_crafted_request(modbus_t *ctx, int function,
{
const int EXCEPTION_RC = 2;
uint8_t rsp[MODBUS_TCP_MAX_ADU_LENGTH];
int j;

for (int j=0; j<2; j++) {
for (j=0; j<2; j++) {
int rc;

req[1] = function;
Expand Down

0 comments on commit 6d9b069

Please sign in to comment.