Re: [ntdev] Getting linking error while Using DOUBLE data type in kernel mode

The short answer is don’t do that.

While it is possible to use FP types and operations in KM, by default the FP state is not available and the concept of performing imprecise arithmetic in KM is generally anathema for systems programmers

Sent from Surface Pro

From: xxxxx@gmail.com
Sent: ‎Thursday‎, ‎December‎ ‎04‎, ‎2014 ‎11‎:‎24‎ ‎AM
To: Windows System Software Devs Interest List

I am trying to use a “double” data type in kernel driver while collecting time stamps using KeQueryPerformanceCounter.

Basically i am calculating the elapsed time for an activity and convert the elapsed time data into a double. Below is the code.

DOUBLE lfTemp = 0;
ullCurrentTimeStamp = KeQueryPerformanceCounter(NULL);
////KeQueryPerformanceFrequency(
ullElapsedMicroseconds.QuadPart = (ullCurrentTimeStamp.QuadPart) - (pstDeviceContext->stPortTimeLog.ullStartUpTimeStamp.QuadPart);
ullElapsedMicroseconds.QuadPart *= 1000;

lfTemp = (double)(ullElapsedMicroseconds.QuadPart / pstDeviceContext->stPortTimeLog.ullFrequency.QuadPart);

I am seeing the below error:

“timer.obj : error LNK2001: unresolved external symbol __fltused”

I don’t see this symbol “__fltused” anywhere in the code.

From a couple of suggestions i found googling for this issue, i tried changing the option of “Ignore all default libraries” in “Linker” tab in the project properties to “No”. But that gave another error.

“LIBCMT.lib(fpinit.obj) : warning LNK4257: object file was not compiled for kernel mode; the image might not run”

I tried addding /kernal option in the “command line options” filed in project properties -> c/c++ sections but it didn’t help.

is there any other additional step that i need to take while using floating data types in kernel mode?

From a couple of articles i found on internet, they suggested not to use double data type at all in kernel mode. But i do need to use it for my requirement.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer