Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Use a Common Include File Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
14-Aug-03
Category
VCL-General
Language
Delphi 2.x
Views
82
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jorge Abel Ayala Marentes 

If you develop third-party components and you plan to include the source code. You 
can not be certain how Delphi is configured for each user, how can you asure that 
your componentīs code compile correctly?

Answer:

You can use a common include file in all your components unit, so you can set 
compiler directives and conditional defines that govern the way the components are 
compiled. 

If the user recompiles your code, its naive to think that his compilers directives 
are the same as the ones you used to develop the components. So creating a common 
include file, you can override the userīs directives. For example you can use the 
following: 

// DCDC Include File
// You must include a similar file into each component unit so it can
// serve as a common place to add conditional defines and compiler
// directives.

// Code Generation Directives

{$O+} //Optimizations
{$F-} //Force Far Calls
{$A+} //Word Align Data
{$U-} //Pentium-Safe FDIV
{$K-} //Smart Callbacks
{$W-} //Windows Stack Frame

// Runtime Errors
{$IFOPT D+}
{$R+} //Range Checking - On - If compiled with Debug Information
{$ELSE}
{$R-} //Range Checking - Off - If compiled without Debug Information
{$ENDIF}

{$S+} //Stack Checking
{$I+} //I/O Checking
{$Q-} //Overflow Checking

// Syntax Options
{$V-} //Strict Var-Strings
{$B-} //Complete Boolean Evaluation
{$X+} //Extended Syntax
{$T-} //Typed @ Operator
{$P+} //Open Parameters
{4H+}//Huge Strings

// Miscellaneus Directives
{$Z-} //Word Size Enumerated Types

Because this is an include file you must use the $I directive to embed its contents 
in your componentīs unit files. 

1   {$I CIF.INC}
2   
3   unit mcEdit;
4   
5   interface
6   
7   uses
8     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
9   
10  type
11    TmcEdit = class(TCustomEdit)
12    private
13      { Private declarations }
14    public
15      { Public declarations }
16    end;


But, what if you create a component that uses a diferent compiler directive?, Just specify the new directive after the include file statements, this overrides the include fileīs directives. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC