Dropped to assembler output on invalid extern

Archives Forums/BlitzMax Bug Reports/Dropped to assembler output on invalid extern

Blueapples(Posted 2008) [#1]
When attempting to build the excellent MicroC library (thread, download) on Mac OS 10.5, I am dumped at a MaxIDE editor window with the file microc.bmx.debug.macosx.x86.s opened to the first line with this error message:

Compile Error
Rest of line ignored. 1st junk character valued 64 (@).


The first few lines look like this:

	.reference	_QueryPerformanceCounter@4
	.reference	_QueryPerformanceFrequency@4
	.reference	___bb_basic_basic
	.reference	___bb_blitz_blitz
	.reference	___bb_retro_retro
	.reference	___bb_system_system


It would appear that the first two are using a syntax not supported by the Mac OS assembler.

The only place (in this file) where QueryPerformanceCounter@4 or _QueryPerformanceFrequency@4 are referenced is:



This function is declared in the file Shared.bmx.



This appears to use a windows-only extern. I can patch this, however the error behavior in this case is very, very confusing. The compiler should stop in the BMX file and indicate that an unsupported Extern is being used.


Azathoth(Posted 2008) [#2]
Use ?win around the Extern


Helios(Posted 2008) [#3]
Yeh Azathoth is correct. Put a ?win32 block around the extern block and add a ?win32 block around the first if statement in HPMillisecs. Very stupid mistake I made >_>


Blueapples(Posted 2008) [#4]
Yes, well I did put that patch in, as I said it was easy to fix. However this is not good behavior, the compiler should report an intelligent error instead of dumping to assembler output on obscure line of assembler syntax.


MrTAToad(Posted 2008) [#5]
But how would the compiler know what is the problem is to generate an intelligent report ?


Blueapples(Posted 2008) [#6]
But how would the compiler know what is the problem is to generate an intelligent report ?

In this case I think it's pretty easy - MacOS doesn't support "Win32", so it would know it should be in ?Win32 ... ? and could easily throw an error on Mac OS and Linux. The code throwing the error was below the fold so I'll repeat it:

Extern "win32"
	Function QueryPerformanceCounter(count:Long Var)
	Function QueryPerformanceFrequency(freq:Long Var)
End Extern


If the compiler can't tell that won't work on Mac OS and Linux, well. Uh. Hmm. It should be able to. ;)


MrTAToad(Posted 2008) [#7]
You wouldn't want to to report an error - you would just want it to be ignored. If you ask Mark nicely, he might add it in before the main release :)


Blueapples(Posted 2008) [#8]

You wouldn't want to to report an error - you would just want it to be ignored. If you ask Mark nicely,


Well, no I really would like to get a notice that I have Windows only code that's about to be dropped, instead of later having a strange "undeclared function" error. It's quite conceivable that I forgot, or never knew, that the given function was Windows-only (for instance if it were declared in a third-party library file that I only skimmed). I'm not sure how to ask Mark for things other than posting here, so uh, Mark plz add this? It would be helpful for us cross-platform people.


he might add it in before the main release :)


Oh, is there a new release coming soon? That'd be awesome! I probably haven't been paying proper attention to the work logs, etc....


MrTAToad(Posted 2008) [#9]
It was suppposed to be out last week-ish.