My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 90: Creating shortcut variable for class fails to be compiled
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Jan 2011


 
Reported by Andy.onthewings, Jan 19, 2011
class Main 
{

	static public function main() 
	{
		var M = Math;
		trace(M.sin(0));
	}
	
}

The above technique is used by physaxe. It fails to be compiled using haxe r3637, hxcpp r283, VS2010.

The error:

D:\workspace\TestHaxeCpp>haxe compile.hxml
haxelib run hxcpp Build.xml haxe -Dcpp -Dhaxe_206 -Dtrue
Using cl version: 16
BuildTool.hx:154: Creating hxcpp.pch.
cl.exe -Iinclude -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -ID:\repo\hxcpp//
include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Ychxcpp.h __pch.cpp /Fphxcpp.pch
__pch.cpp
cl.exe -I. -Iinclude -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -ID:\repo\hxc
pp//include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Yuhxcpp.h ./src/Main.cpp -Foobj/
Release/src/Main.obj
cl.exe -I. -Iinclude -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -ID:\repo\hxc
pp//include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Yuhxcpp.h ./src/__boot__.cpp -Fo
obj/Release/src/__boot__.obj
__boot__.cpp
Main.cpp
cl.exe -I. -Iinclude -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -ID:\repo\hxc
pp//include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Yuhxcpp.h ./src/__resources__.cp
p -Foobj/Release/src/__resources__.obj
./src/Main.cpp(38) : error C2039: 'sin' : is not a member of 'Class_obj'
        d:\repo\hxcpp\include\Class.h(50) : see declaration of 'Class_obj'
Called from ? line 1
Called from BuildTool.hx line 1123
Called from BuildTool.hx line 509
Called from BuildTool.hx line 538
Called from BuildTool.hx line 652
Called from BuildTool.hx line 724
Uncaught exception - Error in building thread
Error : Build failed
Jan 19, 2011
Project Member #1 gameh...@gmail.com
Hmm. This needs fixing.  However, this is also a huge performance hit on c++ and should be #ifed out - I not even sure it is a performance win on flash anymore.
Or at least replaced with var "sin = Math.sin" and save one level of indirection.
Jan 20, 2011
#2 Andy.onthewings
I've just reported it as an issue to physaxe. :)
Jan 20, 2011
#3 ncanna...@gmail.com
It should compile in C++ since it is valid haXe code, and it's still a good optimization for flash9+ since the access to the static class is expensive. Using sin = Math.sin won't help since it will create a closure, slowing things down.

I'll #if the optimization so it doesn't slowdown in C++
Jan 20, 2011
Project Member #4 gameh...@gmail.com
It should compile now.  Still worth to the conditional compile for cpp because the Math functions are automatically inlined.
Status: Fixed

Powered by Google Project Hosting