Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   #if defined INTEL_W32 (http://www.go4expert.com/forums/if-defined-intelw32-t4887/)

jennifer123 25Jun2007 17:09

#if defined INTEL_W32
 
Hello every one, I am using visual C++ tool to debug the following code. However, during a line by line debug, the execution flow DOES NOT move to (#if defined INTEL_W32 ). I am using visual C++ on windows XP .
Can any one kindly tell me what is the MEANING of

#if defined INTEL_W32
===============================================
Debugging following program:

Code:

#if defined INTEL_W32

static Boolean fFirstTime = FALSE;
UInt32 ulLinearAddress;
UInt32 offset;

// Always register the atexit routine at least once, so any allocated
// resources are guaranteed to be released and freed. The function
// halpFreeLinearAddress is fully reentrant, so it can be called
// multiple times, in any order, without causing any harm.
if (!fFirstTime)
{ fFirstTime = TRUE;
printf("fFirstTime = %d \n",fFirstTime); // added
atexit(halpFreeLinearAddress);
}


// Use the configured register address to retrieve the linear address.
// NOTE: for PCI the register address should be zero, causing the VxD
// to locate the S1D13A05 in PCI address space.

if (HalInfo.dwRegisterAddress > HalInfo.dwMemoryAddress)
{
        gnHalErrCode = halpGetLinearAddress(HalInfo.dwMemoryAddress, &ulLinearAddress);
       
       
       
        if (gnHalErrCode != ERR_NONE)
                return FALSE;
       
        offset = HalInfo.dwRegisterAddress - HalInfo.dwMemoryAddress;
       
        if (offset == 0)
                offset = 0x200000;
       
        gpHalMemAddr = (pvUInt32) ulLinearAddress;
        gpHalRegAddr = (pvUInt32)(ulLinearAddress + offset);
       
       
}
else
{
        gnHalErrCode = halpGetLinearAddress(HalInfo.dwRegisterAddress, &ulLinearAddress);
       
        if (gnHalErrCode != ERR_NONE)
                return FALSE;
       
        offset = HalInfo.dwMemoryAddress - HalInfo.dwRegisterAddress;
       
        if (offset == 0)
                offset = 0x200000;
       
        gpHalRegAddr = (pvUInt32) ulLinearAddress;
        gpHalMemAddr = (pvUInt32)(ulLinearAddress + offset);
       
        printf ("<<<<<<<<<gpHalMemAddr, %d \n",gpHalMemAddr); // added
        printf ("<<<<<<<<<gpHalRegAddr, %d \n",gpHalRegAddr); //added
       
       
}

if (pReg)
*pReg = (UInt32) gpHalRegAddr;

if (pMem)
*pMem = (UInt32) gpHalMemAddr;
#else

// ********DEBUGGING WILL CONTINUE FROM HERE ******

gpHalRegAddr = (pvUInt32) HalInfo.dwRegisterAddress; gpHalMemAddr = (pvUInt32) HalInfo.dwMemoryAddress;

if (pReg)
*pReg = HalInfo.dwRegisterAddress;


if (pMem)
*pMem = HalInfo.dwMemoryAddress;




#endif

return TRUE;

}


DaWei 25Jun2007 18:46

Re: #if defined INTEL_W32
 
Statements that begin with # are preprocessor directives. They are processed before the compiler sees the source code. For example, #include <afile> causes the contents of afile to be pasted directly into the source at the point of inclusion. #define myLength 10 causes every occurrence of the word, myLength, to be replaced with the text, 10. All these things are done before the compiler compiles, the linker links.

In the case of #if defined INTEL_W32 (or, usually, just #ifdef INTEL_W32), any material between the #if and a #else or #endif will be included in the source code IF there has been a previous statement defining INTEL_W32. If that value has not been defined, the material will not be included. Obviously, if the material is not included, the code will not be compiled, no executable statements will result.

You should take an hour or so and learn what actually happens in the steps that occur between the pounding of the keyboard and the execution of machine-code statements.

jennifer123 26Jun2007 08:45

Re: #if defined INTEL_W32
 
thank you for replying.... i am sure i understand the purpose of #if defined and #else. BUT WHAT is the meaning of INTEL_W32 does it mean one has to use windows XP or windows 98.

Does 32 refers to the architecture which we are using ? or if there is any platform requirement (like windows 98 or windows XP ) to compile.


All times are GMT +5.5. The time now is 07:09.