- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- main function not executed
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 06:06 AM
тАО10-14-2003 06:06 AM
main function not executed
I compile a program with aCC, but when it runs
it skips the main() completely: I put a print
statement at the very beginning of the main()
function but when I execute the program the
print statement is never called as all other
initializations and it looks like starts running some other piece of code which shouldn't be running unless interaction with
the user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 06:07 AM
тАО10-14-2003 06:07 AM
Re: main function not executed
This can not behappening. What probably is happening is that you have done your printf but not flushed standard output yet with "fflush()" or even "\n" which might explain why you can't see it.
Can I suggest you post the code snippet so we can have a look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 06:12 AM
тАО10-14-2003 06:12 AM
Re: main function not executed
There may be nothing to print (check arguments of 'print' statement), the statement itself can be skipped in the flow of the program, standard output can be redirected, but main() has to be executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2003 06:24 AM
тАО10-14-2003 06:24 AM
Re: main function not executed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2003 04:17 AM
тАО10-15-2003 04:17 AM
Re: main function not executed
The problem was the main() is in C while the
rest of the code is in C++. I followed all
the recommendations of mixing C and C++
objects, and this was working before I
upgraded to Oracle9i (I guess one of the
patches needed by oracle caused this
problem). Before I had to called _main()
in order to create all static objects and I
had control where in the code I called
_main(), but now I gues HP decided that an
explicit call to _main() was not necessary
anymore, so all the creation of static
objects is done automatically as it should
be.
Here is a small example:
file main.c:
int main()
{
/* Initializing communications */
...
/* call app */
func1();
}
file Obj1.C:
/* Globals */
Object1 *obj1 = new Object1();
void func1()
{
...
}
As this example shows the object 'obj1' is
created before even calling main() because
it is a global object. In my application,
the problem was that the constructor of
'Object1' tries to communicate to oracle
and the main application, but the
communication is initialized in main().
In order for this to work properly I changed
the file 'Obj1.C' to:
/* Globals */
Object1 *obj1;
void func1()
{
/* Create global objects */
obj1 = new Object1();
...
}
Now 'obj1' is created when calling func1(),
right after main() already initialized
communications with the main application.
Hope I was able to explain all of this well.
Thanks again for the all the help I got.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2003 05:03 AM
тАО10-15-2003 05:03 AM