NO

Author Topic: Pragma  (Read 3528 times)

fay

  • Guest
Pragma
« on: April 27, 2006, 02:27:24 pm »
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  :)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1882
Pragma
« Reply #1 on: April 27, 2006, 03:33:56 pm »
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).