The following code fails to compile using sdcc, but succeeds with gcc:
/// GPL 2.0 or later
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
void dotest(void) {}
typedef struct {
uint8_t count;
} TestData;
TestData testData;
#define for8( var, size ) unsigned char var; for ( (var) = 0; (var) < (size); (var)++ )
void for1test(void) {
for8(count,testData.count)
{
dotest();
}
}
// sdcc -mz80 ./forbug.c -c
$ sdcc -mz80 ./forbug.c -c
./forbug.c:20: error 26: '' not a structure/union member
gcc ./forbug.c -c -Wall
sdcc -v
SDCC : z80/sm83/z80n/mos6502 TD- 4.3.6 #14442 (Linux)
This is unrelated to the macro: the issuecan be reproduced using this variant:
Last edit: Philipp Klaus Krause 2023-11-20