CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
Can you define which header file to include at compile time?
Category C Interview Questions
Rating (4.0) By 18 users
Added on 10/22/2004
Views 7820
Rate it!
Answers:

Yes. This can be done by using the #if, #else, and #endif preprocessor directives. For example, certain
compilers use different names for header files. One such case is between Borland C++, which uses the header file alloc.h, and Microsoft C++, which uses the header file malloc.h. Both of these headers serve the same purpose, and each contains roughly the same definitions. If, however, you are writing a program that is to support Borland C++ and Microsoft C++, you must define which header to include at compile time. The following example shows how this can be done:


#ifdef _ _BORLANDC_ _
#include <alloc.h>
#else
#include <malloc.h>
#endif



No, we cannot do so since #include's are processed at preprocessor stage, not on compile time. But we can avoid the inclusion of header files by using #ifdef, #ifndef etc.



 Posted by: Manik Sidana    

Contact Manik Sidana  Contact Manik Sidana

Can you define which header file to include at compile time?

Yes. This can be done by using the #if, #else, and #endif preprocessor directives. For example, certain
compilers use different names for header files. One such case is between Borland C++, which uses the header file alloc.h, and Microsoft C++, which uses the header file malloc.h. Both of these headers serve the same purpose, and each contains roughly the same definitions. If, however, you are writing a program that is to support Borland C++ and Microsoft C++, you must define which header to include at compile time. The following example shows how this can be done:


#ifdef _ _BORLANDC_ _
#include <alloc.h>
#else
#include <malloc.h>
#endif



--------------------------------------------------------------------------------

No, we cannot do so since #include's are processed at preprocessor stage, not on compile time. But we can avoid the inclusion of header files by using #ifdef, #ifndef etc.




 Posted by: prema somani    

Contact prema somani  Contact prema somani

Yes. This can be done by using the #if, #else, and #endif preprocessor directives. For example, certain
compilers use different names for header files. One such case is between Borland C++, which uses the header file alloc.h, and Microsoft C++, which uses the header file malloc.h. Both of these headers serve the same purpose, and each contains roughly the same definitions. If, however, you are writing a program that is to support Borland C++ and Microsoft C++, you must define which header to include at compile time. The following example shows how this can be done:


#ifdef _ _BORLANDC_ _
#include <alloc.h>
#else
#include <malloc.h>
#endif


No, we cannot do so since #include's are processed at preprocessor stage, not on compile time. But we can avoid the inclusion of header files by using #ifdef, #ifndef etc.



 Posted by: manish    

Contact manish  Contact manish


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
Can include files be nested?
View Answer
How many levels deep can include files be nested?
View Answer
How can type-insensitive macros be created?
View Answer
What are the standard predefined macros?
View Answer
What is a pragma?
View Answer
What is #line used for?
View Answer
How do you override a defined macro?
View Answer
How can you check to see whether a symbol is defined?
View Answer
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
View Answer
How can I convert a number to a string?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/1024/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.62