This works
dmd -o- png.d simpleaudio.d
This doesn't
dmd -o- simpleaudio.d png.d
core/types.d(8): Error: undefined identifier `__SIZEOF_PTHREAD_MUTEX_T`
---
module simpleaudio;
struct AudioOutputThread
{
alias Sample = AudioPcmOutThreadImplementation.Sample;
}
import core.types;
class AudioPcmOutThreadImplementation
{
void[pthread_mutex_t.sizeof] _slock;
struct Sample { }
}
---
module png;
struct GC
{
import core.types;
}
---
module core.types;
enum __WORDSIZE = 64;
static if (__WORDSIZE)
enum __SIZEOF_PTHREAD_MUTEX_T = 1;
union pthread_mutex_t
{
byte[__SIZEOF_PTHREAD_MUTEX_T] __size;
}
Comment #1 by ibuclaw — 2023-01-03T17:17:08Z
Related test.
---
module simpleaudio;
struct AudioOutputThread
{
alias Sample = AudioPcmOutThreadImplementation.Sample;
}
import core.types;
class AudioPcmOutThreadImplementation
{
pthread_t id;
struct Sample { }
}
---
module png;
struct GC
{
import core.types;
}
---
module core.types;
static if (true)
alias ulong c_ulong;
alias c_ulong pthread_t;
Comment #2 by ibuclaw — 2023-01-03T17:31:54Z
Related test, also has the error:
simpleaudio.d(13): Error: class `Thread` is forward referenced
---
module simpleaudio;
struct AudioOutputThread
{
alias Sample = AudioPcmOutThreadImplementation.Sample;
}
import core.types;
class Thread
{
void[pthread_mutex_t.sizeof] _slock;
}
alias MainThreadStore = void[__traits(classInstanceSize, Thread)];
class AudioPcmOutThreadImplementation : Thread
{
struct Sample { }
}
---
module png;
struct GC
{
import core.types;
}
---
module core.types;
static if (true)
enum __SIZEOF_PTHREAD_MUTEX_T = 1;
union pthread_mutex_t
{
byte[__SIZEOF_PTHREAD_MUTEX_T] __size;
}
Comment #3 by dlang-bot — 2023-01-16T01:26:09Z
@ibuclaw created dlang/dmd pull request #14826 "dmd.aggregate: Define importAll override for AggregateDeclaration" fixing this issue:
- fix Issue 23595 - Error: undefined identifier with static if and module/import order
https://github.com/dlang/dmd/pull/14826
Comment #4 by robert.schadek — 2024-12-13T19:26:34Z