.ch Files

What are .ch files ?

ch means “C header” and as name implied, this coding way borrowed from C language.

Normally, that files written individually and are included into .prg file via #include directive.

In general, .ch files includes pre-processor directives for constant declarations, pseudo functions and commands; including #include directives for other files. These lines are general purpose code line and may or not may #included by more than one .prg files.

For example, say we have some values like :

pi := 22 / 7
MaxUserCount := 10

If we declare this constants as above in the .prg file, this two identifiers are variables.

We can declare that values in another way :

#define pi 22 / 7
#define MaxUserCount 10

In this case this two identifiers are constant, so their values has been fixed, no changeable afterward. #define is a pre-processor directive, these two identifiers are meta-constants and can be use in the code (.prg) file, after defined place ( if defined at top of file, can be use anywhere in that file).

I we want use that two value into other code (.prg) files, we need repeat above two lines (consider a quite large list) for all that code (.prg) files. And of course when a modification required, we need edit all code files.

In this case we build a .ch file that contains that definitions and add an #include directive to code files that need this definitions.

That’s all.

.ch file extension is a general tradition and doesn’t implies any specific action to compiler.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.