ooc-lang / rock

:ocean: self-hosted ooc compiler that generates c99
http://ooc-lang.org/
MIT License
403 stars 40 forks source link

INT_MIN is a literal, FLT_MIN is an extern #926

Closed davidhesselbom closed 8 years ago

davidhesselbom commented 8 years ago

In Numbers.ooc:


//INT_MIN,    INT_MAX  : extern const static Int
//UINT_MAX           : extern const static UInt
//LONG_MIN,  LONG_MAX  : extern const static Long
//ULONG_MAX          : extern const static ULong
//LLONG_MIN, LLONG_MAX : extern const static LLong
//ULLONG_MAX             : extern const static ULLong

INT_MAX := 2147483647
INT_MIN := -INT_MAX - 1
INFINITY: extern Double
NAN: extern Double
FLT_MIN: extern Float
DBL_MIN: extern Double

How come the limits for Int are set like this, but the rest are extern? Is it just something that hasn't been fixed, or is it, in fact, a fix for something?

horasal commented 8 years ago

By git log -S 2147483647 --source --all, I find it is introduced here

commit 3d49553721fe803d76c89be06a84f97a91db7ce5 
Author: nddrylliog <nddrylliog@gmail.com>
Date:   Wed Apr 21 09:59:51 2010 +0200

    INT_MIN fixes, Win32 fixes for SdkLocator and Module, MakeDriver improvement (OS/machine detection)

I can't point out the exact reason, but there's no different for me between literal and extern. Maybe the bug has been fixed.

fasterthanlime commented 8 years ago

2010! Perhaps back then I was building in an environment lacking INT_MIN / a proper limits.h ?

davidhesselbom commented 8 years ago

Yeah, I know, it's been a long time! :) So you don't remember making it a literal to prevent some problem related to the system bitness or anything (I doubt you've ever run rock on a 16-bit system, but what do I know)?

Were the comments supposed to replace the literals when you got a proper limits.h, but then that never happened? And, should it be const static, and does it matter?

fasterthanlime commented 8 years ago

don't remember

Nope! No idea. Maybe I wanted to take the address of INT_MIN and needed it to be a proper variable.

const static

I'm not sure rock passes const to the C compiler anymore, and static would just confine it to the file afaict?

davidhesselbom commented 8 years ago

No, you're right, const is ignored... alright, well, no harm in changing it then. Thanks!

davidhesselbom commented 8 years ago

Fixed by #927.