Fix extern undefined struct in header file

This commit is contained in:
drmortalwombat 2024-06-15 17:24:04 +02:00
parent 58361e39b8
commit b428b608b5
3 changed files with 35 additions and 8 deletions

View File

@ -2463,6 +2463,10 @@ bool Declaration::IsSame(const Declaration* dec) const
return true; return true;
if (mType != dec->mType) if (mType != dec->mType)
return false; return false;
if (!(mFlags & dec->mFlags & DTF_DEFINED) && mType == DT_TYPE_STRUCT)
return mIdent == dec->mIdent;
if (mSize != dec->mSize) if (mSize != dec->mSize)
return false; return false;
if (mStripe != dec->mStripe) if (mStripe != dec->mStripe)

View File

@ -4554,8 +4554,10 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
{ {
if (!ndec->mBase->IsSame(pdec->mBase)) if (!ndec->mBase->IsSame(pdec->mBase))
{ {
if (ndec->mBase->mType == DT_TYPE_ARRAY && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase) && pdec->mBase->mSize == 0) if (ndec->mBase->mType == DT_TYPE_ARRAY && pdec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase))
pdec->mBase->mSize = ndec->mBase->mSize; {
pdec->mBase = ndec->mBase;
}
else if (pdec->mBase->mType == DT_TYPE_POINTER && ndec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase)) else if (pdec->mBase->mType == DT_TYPE_POINTER && ndec->mBase->mType == DT_TYPE_ARRAY && ndec->mBase->mBase->IsSame(pdec->mBase->mBase))
{ {
pdec->mBase = ndec->mBase; pdec->mBase = ndec->mBase;
@ -4563,6 +4565,8 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
else else
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent); mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Variable declaration differs", ndec->mIdent);
} }
else
pdec->mBase = ndec->mBase;
if (!(ndec->mFlags & DTF_EXTERN)) if (!(ndec->mFlags & DTF_EXTERN))
{ {

View File

@ -8,6 +8,9 @@
// Lookup table for squares from 0..255 // Lookup table for squares from 0..255
__striped unsigned sqb[256]; __striped unsigned sqb[256];
// Shift byte right and left by 4
char shlb4[256], shrb4[256];
#pragma align(sqb, 256); #pragma align(sqb, 256);
// Square an unsigned int into an unsigned long // Square an unsigned int into an unsigned long
@ -103,6 +106,16 @@ static const char colors[32] = {
VCOL_DARK_GREY, VCOL_DARK_GREY,
}; };
inline int shr12(long l)
{
char b3 = (l >> 24) & 0xff;
char b2 = (l >> 16) & 0xff;
char b1 = (l >> 8) & 0xff;
char a0 = shrb4[b1] | shlb4[b2];
char a1 = shrb4[b2] | shlb4[b3];
return a0 | (a1 << 8);
}
// Return color for a given coordinate in the complex plane using // Return color for a given coordinate in the complex plane using
// 12.4bit fixed numbers using m'=m²+b // 12.4bit fixed numbers using m'=m²+b
@ -119,15 +132,17 @@ inline char fcolor(int xz, int yz)
// Build squares of real and imaginary component // Build squares of real and imaginary component
long xx = sq(x), yy = sq(y), xxyy = sq(x + y); long xx = sq(x), yy = sq(y), xxyy = sq(x + y);
// Use squares to check for exit condition of sure long xxpyy = xx + yy;
// to proress towards infinity
if (xx + yy >= 4L * 4096 * 4096) return colors[i];
// Next iteration values using complex artithmetic // Use squares to check for exit condition of sure
// to progress towards infinity
if (xxpyy >= 4L * 4096 * 4096) return colors[i];
// Next iteration values using complex arithmetic
// Mx' = Mx² - My² + Bx // Mx' = Mx² - My² + Bx
// My' = 2 * Mx * My + By = (Mx + My)² - Mx² - My² + By // My' = 2 * Mx * My + By = (Mx + My)² - Mx² - My² + By
x = ((xx - yy + 2048) >> 12) + xz; x = shr12(xx - yy + 2048) + xz;
y = ((xxyy - xx - yy + 2048) >> 12) + yz; y = shr12(xxyy - xxpyy + 2048) + yz;
} }
// More than maximum number of iterations, so assume progress // More than maximum number of iterations, so assume progress
@ -225,7 +240,11 @@ int main(void)
{ {
// Initialize square table // Initialize square table
for(unsigned i=0; i<256; i++) for(unsigned i=0; i<256; i++)
{
sqb[i] = i * i; sqb[i] = i * i;
shlb4[i] = i << 4;
shrb4[i] = i >> 4;
}
// Clear screen // Clear screen
memset(Screen, 160, 1024); memset(Screen, 160, 1024);