News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Pragma

Started by fay, April 27, 2006, 02:27:24 PM

Previous topic - Next topic

fay

I need a clarification about #pragma directive.
When I compiled and ran the below code in Turbo-C++ compiler it is running fine. But when I tried to run the same code in VC++6.0 compiler it is giving two warnings as "Unknown Pragma"... it is not recognizing the key words Startup and exit. That is why the warnings a coming. Can you pls mention the equivalent CPP code which can run on a VC++6.0 compiler.

The code is as below:

#include<iostream.h>
#include<conio.h>
void f1();
void f2();
#pragma startup f1
#pragma exit f2

main()
{
cout<<"EXECUTING MAIN \ n \ n";
return(0);
}


void f1()
{
cout<<"EXECUTING F1 \ n \ n";
}

void f2()
{
cout<<"EXECUTING F2 \ n \ n";
}

Thanks in advance  :)

frankie

fay, I would inform you that PellesC is not a C++ compiler, and people on this forum may not be C++ skilled.
Just to fast answer to your question: the standard permits to #pragma operator to have some personalized options (available only on that specific compiler). The standard says that when a compiler found an unknown pragma it must just ignore it (and in effect you get a warning).
In your case they seems to define the routine called at program startup and that called on program exit, so for the VC I suggest you to check in the linker options if there is any that could mimic that pragmas (to set the startup routine use "/entry:f1", I don't know for the other).
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide