Software Archive
Read-only legacy content
17060 Discussions

Some initial issues, variable types and long doubles treatment

MPere15
Novice
3,225 Views

Hello,

Do long doubles need a special treatment? Anyone know a reason why the would stop working properly?

I've recently started to migrate my project to Paralell Studio.
So far, the setup is ok, and I have sample projects up and running, that use Intel C++ compiler.
Now, I have problems with the main project. It is a DirectX 3d software, and it uses a wide set of libraries.
Program loads and starts and I can tell that it is running, however, it is not working as expected, because none of the objects are being positioned.

Since positions are stored in long double variable type, I was thinking that this could be related, as I see other posts about long doubles here in the forum.

It even fails with all the .cpp files using Microsoft compiler (while Intel C++ is still the project compiler, just used for linking).

So, once again, do long doubles need a special treatment?
Are there any other variable type with special treatment? (variable definitions, assignements, operations..)

Thanks in advance

0 Kudos
1 Solution
SergeyKostrov
Valued Contributor II
3,201 Views
Quoting mpl3d
...Regarding the FPU settings I do need to set it like this

#pragma fenv_access (on)
unsigned int cw = _control87(0, 0);
_clear87();
_control87(0x00000000, 0x00030000);
...


Yes, it will work. However, you have to be very carefull when using constants in '_control87' functioninstead macros
defined in 'float.h' header file. It will work for Microsoft, Intel and MinGW C++ compilers, and it won't work for Borland and
Turbo C++ compilers. A better versionlooks like:

...
_control87( _CW_DEFAULT, _MCW_PC );
...

Using a_PC_64 macrois useless when sizeof( long double ) is equal to 8. It won't make a precision of FP-calculations better and
is actually the same as if you woulduse a_PC_53 macro.

View solution in original post

0 Kudos
27 Replies
SergeyKostrov
Valued Contributor II
605 Views
Quoting mpl3d
...However, I've uploaded the library '3DMaths.lib' here, perhaps you would like to inspect it:

http://dc613.4shared.com/download/ihywqMym/3DMaths.lib

[SergeyK] Downloaded and I'm about to start investigation.


It is already in progress and I have some linker problems. Please take a look:

Here is a Summary:

It looks like another library is needed because 3DMaths.lib uses 2 external functions and one external structure:

IDirect3DDevice9 * __cdecl dbGetDirect3DDevice(void)
void * __cdecl dbGetCameraInternalData(int)
struct GlobStruct * g_pGlob

Here is a Compilation Report ( with MS C++ compiler of VS 2005 ):

------ Build started: Project: 3DMathsTestApp, Configuration: Release Win32 ------
Compiling...
3DMathsTestApp.cpp
Linking...
3DMaths.lib(cVectorC.obj) : error LNK2001: unresolved external symbol "struct IDirect3DDevice9 * __cdecl dbGetDirect3DDevice(void)" (?dbGetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ)
3DMaths.lib(cVectorC.obj) : error LNK2001: unresolved external symbol "void * __cdecl dbGetCameraInternalData(int)" (?dbGetCameraInternalData@@YAPAXH@Z)
3DMaths.lib(CError.obj) : error LNK2001: unresolved external symbol "struct GlobStruct * g_pGlob" (?g_pGlob@@3PAUGlobStruct@@A)
C:\WorkEnv.Test\3DMathsTestApp\Release\3DMathsTestApp.exe : fatal error LNK1120: 3 unresolved externals
3DMathsTestApp - 4 error(s), 0 warning(s)

------ Build started: Project: 3DMathsTestApp, Configuration: Debug Win32 ------
Compiling...
3DMathsTestApp.cpp
Linking...
3DMaths.lib(cVectorC.obj) : error LNK2019: unresolved external symbol "struct IDirect3DDevice9 * __cdecl dbGetDirect3DDevice(void)" (?dbGetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ) referenced in function "void __cdecl Constructor(struct HINSTANCE__ *)" (?Constructor@@YAXPAUHINSTANCE__@@@Z)
3DMaths.lib(cVectorC.obj) : error LNK2019: unresolved external symbol "void * __cdecl dbGetCameraInternalData(int)" (?dbGetCameraInternalData@@YAPAXH@Z) referenced in function "void __cdecl PassCoreData(void *)" (?PassCoreData@@YAXPAX@Z)
3DMaths.lib(CError.obj) : error LNK2019: unresolved external symbol "struct GlobStruct * g_pGlob" (?g_pGlob@@3PAUGlobStruct@@A) referenced in function "void __cdecl RunTimeError(unsigned long,char *)" (?RunTimeError@@YAXKPAD@Z)
C:\WorkEnv.Test\3DMathsTestApp\Debug\3DMathsTestApp.exe : fatal error LNK1120: 3 unresolved externals
3DMathsTestApp - 4 error(s), 0 warning(s)

========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

0 Kudos
SergeyKostrov
Valued Contributor II
605 Views
Here is aVS 2005test project:'3DMathsTestApp.zip'( attached ).
0 Kudos
MPere15
Novice
605 Views
Hi Sergey,

The file was verified. Sorry for the inconveniences.
I've uploaded it again in .zip format, please check the private post.

Those unresolved are from other .lib files, Camera.lib, Display.lib, and so on.
I think it is not possible to use 3DMaths.lib without them, and as soon these are included, they generate new dependencies.
Please use the full libraries (all of them) in the new .zip file.

Also, no need to try debug configuration. I think these libs are only for release mode.

Nevertheless, the project code that you attached looks fine to me for a test.
You know, just put the folders in the .zip file at the corresponding VS paths for includes and libs and you should be done.

However, I think that if you use VS2005 / DX SDK June 2007, we could find new compiling issues.
Just please let me know if any.

Many thanks,
Manuel
0 Kudos
SergeyKostrov
Valued Contributor II
605 Views
Quoting mpl3d
...Those unresolved are from other .lib files, Camera.lib, Display.lib, and so on.
I think
it is not possible to use 3DMaths.lib without them, and as soon these are included, they generate new dependencies.
Please use the full libraries (all of them) in the new .zip file...

Yes, I confirm that.I tried to usealinker option /FORCE and itdoesn't forceall unresolved references to be resolved.
I used all libraries thatyou've provided.

Best regards,
Sergey
0 Kudos
SergeyKostrov
Valued Contributor II
605 Views
Zip-archive with latestsources attached. You can useVisual Studio 2005 ( Pro )or 2008 ( Pro / Express )now.

Best regards,
Sergey
0 Kudos
MPere15
Novice
605 Views
Thanks Segey,

I expected something like:

Vector Values: [ X=0.000000 Y=0.000000 Z=0.000000 ]

That is, these kind of functions were returning 0.0 in the main project. That was the latest identified problem.
So it seems that at least these functions are working fine in an isolated test.

I can't test your project now, but I'll check it out when I arrive to my office.

I think I'll reinstall Parallel Studio in my laptop so I can continue testing (no news so far from Intel Development Support).

Best regards,
Manuel

0 Kudos
SergeyKostrov
Valued Contributor II
605 Views
Quoting mpl3d
I expected something like:

Vector Values: [ X=0.000000 Y=0.000000 Z=0.000000 ]

[SergeyK]I think there issome internal error(s) in the libraries.


Manuel,What C++ compilerdid you use tobuild the libraries?

I also commented out calls todbPrintand dbSuspendForKey functions. Take a look as soon as you have time:

[cpp]void _tmain( void ) { #ifdef _DEBUG TCHAR szConfiguration[] = _T("DEBUG"); #else TCHAR szConfiguration[] = _T("RELEASE"); #endif _tprintf( _T("Tests Started [ %s configuration ]n"), &szConfiguration[0] ); // Declare float test_valueX = 0.0f; float test_valueY = 0.0f; float test_valueZ = 0.0f; // Use math funcions dbMakeVector3( 1 ); // Create Vector3 dbSetVector3( 1, 1.0f, 2.0f, 3.0f ); // Set Vector3 components // Verify test_valueX = dbXVector3( 1 ); // Recover component X value of the Vector3 test_valueY = dbYVector3( 1 ); // Recover component Y value of the Vector3 test_valueZ = dbZVector3( 1 ); // Recover component Z value of the Vector3 _tprintf( _T("Vector Values: [ X=%f Y=%f Z=%f ]n"), test_valueX, test_valueY, test_valueZ ); // Print Vector3 values // dbPrint( ( double )test_valueX ); // Doesn't display value ( commented out ) // dbPrint( ( double )test_valueY ); // Doesn't display value ( commented out ) // dbPrint( ( double )test_valueZ ); // Doesn't display value ( commented out ) _tprintf( _T("Tests Completedn") ); // Press any key // dbSuspendForKey(); // Something is wrong ( commented out ) }
[/cpp]
0 Kudos
Reply