473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

entry point

Hi all,
I would like to know whether we can specify another function instead
of main as entry point.
Thanks
Aneesh
Nov 13 '05 #1
6 4272
aneesh wrote:
I would like to know whether we can specify another function instead
of main as entry point.


Aneesh...

I must be missing something. The file containing main need not be
named main.c - main /is/ how you specify the executable's entry
point. If you want some other function than the one you called
main to be the primary entry point, then just rename the current
main to something else and call the other function main.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #2
Morris Dovey <mr*****@iedu.com> scribbled the following:
aneesh wrote:
I would like to know whether we can specify another function instead
of main as entry point.
Aneesh... I must be missing something. The file containing main need not be
named main.c - main /is/ how you specify the executable's entry
point. If you want some other function than the one you called
main to be the primary entry point, then just rename the current
main to something else and call the other function main.


Where did you see Aneesh mention main.c?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"The question of copying music from the Internet is like a two-barreled sword."
- Finnish rap artist Ezkimo
Nov 13 '05 #3
Joona I Palaste wrote:
Morris Dovey <mr*****@iedu.com> scribbled the following:
aneesh wrote:
I would like to know whether we can specify another function instead
of main as entry point.

Aneesh...

I must be missing something. The file containing main need not be
named main.c - main /is/ how you specify the executable's entry
point. If you want some other function than the one you called
main to be the primary entry point, then just rename the current
main to something else and call the other function main.

Where did you see Aneesh mention main.c?


Joona...

Nowhere; but suggested as a possibility by the wording of the
question. Do you think I reached too far in trying to understand
where the question was coming from?
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #4
On 30 Jul 2003 02:34:56 -0700
an********@hotmail.com (aneesh) wrote:
Hi all,
I would like to know whether we can specify another function instead
of main as entry point.
Thanks
Aneesh


Yes, we can, but how it's done is linker-specific. Arguments -e and --entry for
the GNU linker, for example. Try the newsgroup for your compiler, or read
it's documentation.

--
main(int c,char*k,char*s){c>0?main(0,"adceoX$_k6][^hn","-7\
0#05&'40$.6'+).3+1%30"),puts(""):*s?c=!c?-*s:(putchar(45),c
),putchar(main(c,k+=*s-c*-1,s+1)):(s=0);return!s?10:10+*k;}
Nov 13 '05 #5
aneesh wrote:
Hi all,
I would like to know whether we can specify another function instead
of main as entry point.


Not in a hosted environment, which is what you are probably using. In a
freestanding environment, the required "designated function" to be
executed at start-up need not be named "main," although it often is.

Nov 13 '05 #6
Pieter Droogendijk wrote:
On 30 Jul 2003 02:34:56 -0700
an********@hotmail.com (aneesh) wrote:
Hi all,
I would like to know whether we can specify another function instead
of main as entry point.
Thanks
Aneesh

Yes, we can, but how it's done is linker-specific. Arguments -e and --entry for
the GNU linker, for example. Try the newsgroup for your compiler, or read
it's documentation.


Er...

On GNU/Linux the default entry point for an ELF executable is named
_start, which is library function contained in libgcc_s (or sometimes
libc on older systems). _start hoiks the command and arguments out of
the OS-defined ABI positions and reformats them to the correct C ABI
positions for argc, argv (and argp, but lets not talk about that), then
calls main.

A similar bit of sysabi-specific code deals with the return vale of main
(or the argument ot exit()), it's usually called _exit.

So in fact, yes you can define the entry point to any symbol you desire,
_but_ you will be replacing _start and not main, and you almost
certainly don't want to do that.

I'd personally go for either a wrapper main function, or quicker but
dirtier, adding -Dmyfun=main to the preprocessor flags (CPPFLAGS).

Phil

Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sam Fields | last post by:
I have found very little regarding the error "Unable to find an entry point named EnumerateSecurityPackagesW in DLL security.dll. ". I have an ASP.NET Web Service being accessed via SSL. I found...
1
by: I am Sam | last post by:
Hi Everyone, I am new to Server control development and I am wondering how do I define the entry point for a server control? In a regular page you define Page_Load as an entry point and in a...
1
by: TRI_CODER | last post by:
I am trying to solve the following exception. The exception occurs when my ASP.NET code behind code attemtps to access a remore site using SSL. Please note that all certificates are valid and the...
5
by: Mike in Santa Rosa | last post by:
I'm trying to get a simple c# app built that can launch/manipulate an excel workbook, sheet. I've chased down several examples and can't any of them to work. So I must be doing somethnig obviouslt...
2
by: bboule | last post by:
Hi I have developped a dll that I want to use in another program ! here is my code : using System; using System.Collections.Generic; using System.Text; namespace NameSpace
10
by: Lung.S.wu | last post by:
Hi all, It is a history question. Recently, I read the book "C A reference manual, third edition". In this book, it list all C language keyword, and one is "entry". I know it is omitted from...
3
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am a developer from C++ COM to C# COM. I feel confused about the entry point function for a C# COM object. In C++, we always initialize object through GetClassObject or...
2
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am implementing a simple C# OLE DB Provider (C# COM Server). For C# (managed code), I am wondering what is the entry point (which coclass and which method), client will...
0
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I have built MSDN OLE DB Sample Provider and successfully built/debug it using Microsoft Excel as client. I have found that in DllGetClassObject (classfac.cpp), the class...
5
by: Premkumar | last post by:
a.cpp ---------------------------------- #include <iostream> using namespace std; void mymain() { cout<<"my-main"<<endl; } ----------------------------------
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.