Friday, February 19, 2010

until you

rebuild the iostream library with the same option.

- If you use word alignment (-a or Options|Compiler|Code

Generation|Word alignment) in building a Turbo Vision

application, you must build the Turbo Vision library from

source with the same option.

assembly language function

assembly language function names to be called by Turbo C++. Your

assembly language program should be assembled with Case Sensitivity.

If compiling as C++ (rather than C), see the "Common C++ Questions"

section above which discusses the use of extern "C".

Q: I am getting an error out of the linker "segment group exceeds 64K :

_text".

A: If you are using the BGIOBJ utility, the default segment into which

the objects will be place is _text. You should try using BGIOBJ with

the /f option to place the resultant objects into a separate segment.

You will then need to use the functions registerfarbgidriver and

registerfarbgifont to register the objects for the graphics system.

See UTIL.DOC for instructions on using these functions.

Q: I am attempting to link Turbo C 2.0 objects into my Turbo C++ programs,

but continually get unresolved external symbols at link time.

A: The names of many of the "helper" functions have changed from what they

were in Turbo C 2.0. If you are getting undefined symbols like _LXLSH and

_FMUL, this is the problem you are running into. Your best solution is to

get the source code to the old object modules and recompile with Turbo C++.

The only other possibility would be to extract the helper function objects

from the Turbo C 2.0 libraries and link them into the Turbo C++ program.

Q. I'm porting an application that uses communal variables to C++.

I've set up the compiler to recognize them, but I still get linker

errors:

Error: defined in module is duplicated in module

A. C++ doesn't support explicit COMDEFs; you must use static

variables or switch to C.

O t h e r Q u e s t i o n s

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

Q. I get a "floating point formats not linked" message when I run

my program. What can I do about it?

A. Floating point formats (for scanf() and related functions) are

not always linked, for savings in executable size. To force their

inclusion, put the following somewhere in your source files:

extern unsigned _floatconvert;

#pragma extref _floatconvert

Q. How do I change the stack size?

A. The size of the stack of a Turbo C++ program is determined at

run time by the global variable _stklen. To change the size

to, for example, 10,000 bytes, include the following line in

your program:

extern unsigned _stklen = 10000;

This statement must not be inside any function definition.

The default stack size is 4,096 bytes (4K).

Q. I'm getting a 'Stack Overflow!' message when I run my program.

How can I work around this?

A. You may increase the stack size by

assembly language function

assembly language function names to be called by Turbo C++. Your

assembly language program should be assembled with Case Sensitivity.

If compiling as C++ (rather than C), see the "Common C++ Questions"

section above which discusses the use of extern "C".

Q: I am getting an error out of the linker "segment group exceeds 64K :

_text".

A: If you are using the BGIOBJ utility, the default segment into which

the objects will be place is _text. You should try using BGIOBJ with

the /f option to place the resultant objects into a separate segment.

You will then need to use the functions registerfarbgidriver and

registerfarbgifont to register the objects for the graphics system.

See UTIL.DOC for instructions on using these functions.

Q: I am attempting to link Turbo C 2.0 objects into my Turbo C++ programs,

but continually get unresolved external symbols at link time.

A: The names of many of the "helper" functions have changed from what they

were in Turbo C 2.0. If you are getting undefined symbols like _LXLSH and

_FMUL, this is the problem you are running into. Your best solution is to

get the source code to the old object modules and recompile with Turbo C++.

The only other possibility would be to extract the helper function objects

from the Turbo C 2.0 libraries and link them into the Turbo C++ program.

Q. I'm porting an application that uses communal variables to C++.

I've set up the compiler to recognize them, but I still get linker

errors:

Error: defined in module is duplicated in module

A. C++ doesn't support explicit COMDEFs; you must use static

variables or switch to C.

O t h e r Q u e s t i o n s

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

Q. I get a "floating point formats not linked" message when I run

my program. What can I do about it?

A. Floating point formats (for scanf() and related functions) are

not always linked, for savings in executable size. To force their

inclusion, put the following somewhere in your source files:

extern unsigned _floatconvert;

#pragma extref _floatconvert

Q. How do I change the stack size?

A. The size of the stack of a Turbo C++ program is determined at

run time by the global variable _stklen. To change the size

to, for example, 10,000 bytes, include the following line in

your program:

extern unsigned _stklen = 10000;

This statement must not be inside any function definition.

The default stack size is 4,096 bytes (4K).

Q. I'm getting a 'Stack Overflow!' message when I run my program.

How can I work around this?

A. You may increase the stack size by

L i n k e r E r r o r s

L i n k e r E r r o r s

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

Q. I am linking C functions with C++ functions. The linker reports that

all of my C functions are undefined. Why?

A. Linking C++ modules with C modules requires the use of a linkage

specification. Prototypes for C functions within C++ modules must

be in one of the following forms:

extern "C" declaration

extern "C" { declarations }

For example, if a C module contains functions

"char *SCopy(char*, char*);" and "void ClearScreen(void)", they

must be declared in a C++ module in one of the following ways:

extern "C" char *SCopy(char*, char*);

extern "C" void ClearScreen(void);

or

extern "C" {

char *SCopy(char*, char*)

void ClearScreen(void);

}

For further examples, see the standard header files. For additional

comment, see Common C++ Questions.

Q. Why do I get the message:

Linker Error: Unable to open input file 'C0x.OBJ'

A. See the "Integrated Environment" section above.

Q. Why do I get the message:

Linker Error: Undefined symbol '_main' in module C0

A. Every C program must contain a function called main(). This

is the first function executed in your program. The function

name must be all in lower case. If your program does not

have one, create one. If you are using multiple source files,

the file that contains the function main() must be one of

the files listed in the Project.

Note that an underscore character '_' is prepended to all

external Turbo C++ symbols.

Q. Why does the linker tell me that all the graphics library

routines are undefined?

A. See the "Integrated Environment" and "Command-line Compiler"

sections above.

Q. What is a 'Fixup overflow'?

A. See the listing of TLINK error messages in the Turbo C++

User's Guide.

Q. I am linking my own assembly language functions with Turbo C++.

The linker reports that all of my functions are undefined.

A. Make sure that you have put an underbar character

L i n k e r E r r o r s

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

Q. I am linking C functions with C++ functions. The linker reports that

all of my C functions are undefined. Why?

A. Linking C++ modules with C modules requires the use of a linkage

specification. Prototypes for C functions within C++ modules must

be in one of the following forms:

extern "C" declaration

extern "C" { declarations }

For example, if a C module contains functions

"char *SCopy(char*, char*);" and "void ClearScreen(void)", they

must be declared in a C++ module in one of the following ways:

extern "C" char *SCopy(char*, char*);

extern "C" void ClearScreen(void);

or

extern "C" {

char *SCopy(char*, char*)

void ClearScreen(void);

}

For further examples, see the standard header files. For additional

comment, see Common C++ Questions.

Q. Why do I get the message:

Linker Error: Unable to open input file 'C0x.OBJ'

A. See the "Integrated Environment" section above.

Q. Why do I get the message:

Linker Error: Undefined symbol '_main' in module C0

A. Every C program must contain a function called main(). This

is the first function executed in your program. The function

name must be all in lower case. If your program does not

have one, create one. If you are using multiple source files,

the file that contains the function main() must be one of

the files listed in the Project.

Note that an underscore character '_' is prepended to all

external Turbo C++ symbols.

Q. Why does the linker tell me that all the graphics library

routines are undefined?

A. See the "Integrated Environment" and "Command-line Compiler"

sections above.

Q. What is a 'Fixup overflow'?

A. See the listing of TLINK error messages in the Turbo C++

User's Guide.

Q. I am linking my own assembly language functions with Turbo C++.

The linker reports that all of my functions a

G r a p h i c s


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

Q. Why do I get the error message:

BGI Error: graphics not initialized (use 'initgraph')

when I use a graphics function? My program has already

called initgraph().

A. For some reason initgraph() failed. To find out why, check

the return value of graphresult(). For example:

#include

int main(void)

{

int gerr; /* graphics error */

int gdriver = DETECT, gmode;

/* Initialize graphics using auto-detection and look

for the .BGI and .CHR files in the C:\TC\BGI directory.

*/

initgraph(&gdriver, &gmode, "C:\\TC\\BGI");

if ((gerr = graphresult()) != grOk)

{

printf("Error : %s\n", grapherrormsg(gerr));

exit(1);

}

:

}

M a t h / F l o a t i n g P o i n t

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

Q. Why do I get incorrect results from all the math library

functions like cos(), tan() and atof()?

A. You must #include before you call any of the standard

Turbo C++ math functions. In general, Turbo C++ assumes that a function

that is not declared returns an int. In the case of math functions,

they usually return a double. For example

/* WRONG */ /* RIGHT */

#include

int main(void) int main(void)

{ {

printf("%f", cos(0)); printf("%f", cos(0));

} }

Q. How do I "trap" a floating-point error?

A. See the signal() and matherr() functions in the online help. The

signal() function may be used to trap errors in the 80x87 or the

80x87 emulator. The matherr() function traps errors in the Math

Library functions.

Turbo C++'s TINY model is compatible with the COM format, but programs

that use Turbo C++'s floating-point routines cannot be used in a

TINY model application.