Comment #0 by adam.chrapkowski — 2010-01-26T13:31:37Z
Forward reference fails when declaration is inside static if statement.
example:
//------------------------------------------------
const FOO_VER = 2;
static if(FOO_VER >= 2) // If Bar is defined
struct Bar { // Foo should be defined too.
Foo foo;
}
static if(FOO_VER >= 1)
struct Foo {
}
//------------------------------------------------
error: identifier 'Foo' is not defined
error: 'Foo' is used as a type
error: variable 'main.Bar.foo' voids have no value
The problem occurs for structures and classes, but not for functions:
The following work correctly:
//------------------------------------------------
static if(FOO_VER >= 2)
class Bar {
this(){ func(); };
}
static if(FOO_VER >= 1)
void func(){ }
//------------------------------------------------
static if(FOO_VER >= 2)
void func(){ Foo foo; }
static if(FOO_VER >= 1)
struct Foo {
}
Comment #1 by flyboynw — 2014-05-22T03:21:35Z
Updating this bug. Note that this effects Aurora Graphics.
The following will produce an 'undefined identifier' error in struct DWRITE_GLYPH_RUN on IDWriteFontFace
static if(DX110)
{
public struct DWRITE_GLYPH_RUN {
IDWriteFontFace fontFace; //Error: Undefined Identifier
//...
}
}
static if(DX111) { //...}
static if(DX112) { //...}
static if(DX110)
{
public interface IDWriteFontFace : IUnknown
{
HRESULT GetDesignGlyphMetrics(const(uint*) Indices, uint Count, DWRITE_GLYPH_METRICS*
//...
}
}
static if(DX111) { //...}
static if(DX112) { //...}
Comment #2 by dbugz — 2015-05-01T07:50:02Z
I think I ran into this issue when I tried to import core.sys.posix.sys.types.off_t in core.stdc.stdio, for use in the fpos_t definition on linux. Commenting out the "static if" block around off_t fixed the issue, so it's definitely related to "static if" somehow.
Comment #3 by robert.schadek — 2024-12-13T17:51:18Z