changing entry point


 
Thread Tools Search this Thread
Top Forums Programming changing entry point
# 1  
Old 02-13-2006
changing entry point

hi...
just wanted to check how i can the entry point of a program...
i tried using the #pragma directive but it doesnt seem to be workin...

Code:
#pragma comment(linker,"/ENTRY:startupfunction")
#include<stdio.h>

void startupfunction()
{
	printf("in print\n");
	main();
}

int main()
{
	printf("in main\n");
	return 0;
}

# 2  
Old 02-13-2006
You can't do that.

The C standard dictates that code (usually called _start ) create things like stdin, stdout, etc. It has to run BEFORE main() and after main(), since it called main(). In the "after" part _start calls the exit routines you declare in atexit(), for example. Then it executes image rundown code, closing stdin, etc.

You would have to replace _start and _exit and other code in the libc library with your own version. Then link your code against your special version of libc.

May I ask why you think you need this entrypoint?
# 3  
Old 02-16-2006
i dont exactly need it... a friend of mine told me that it could be done with the pragma directive...
# 4  
Old 02-16-2006
#pragma

is completely compiler dependent. It may well be that a compiler supports this feature.
The reason main() is a function is because it's called by something. That something has to run before main() can come into play.
# 5  
Old 02-17-2006
Quote:
Originally Posted by jim mcnamara
#pragma

is completely compiler dependent. It may well be that a compiler supports this feature.
The reason main() is a function is because it's called by something. That something has to run before main() can come into play.
oh now i get it... my friends more of a windows guy thats why maybe his compiler supports it...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a new mount point with 600GB and add 350 GBexisting mount point? IN AIX

How to create a new mount point with 600GB and add 350 GBexisting mount point Best if there step that i can follow or execute before i mount or add diskspace IN AIX Thanks (2 Replies)
Discussion started by: Thilagarajan
2 Replies

2. Shell Programming and Scripting

How to replace multiple "&nbsp;" entry with in <td> tag into single entry using sed?

I have the input file like this. Input file: 12.txt 1) There are one or more than one <tr> tags in same line. 2) Some tr tags may have one <td> or more tna one <td> tags within it. 3) Few <td> tags having "<td> &nbsp; </td>". Few having more than one "&nbsp;" entry in it. <tr> some td... (4 Replies)
Discussion started by: thomasraj87
4 Replies

3. Shell Programming and Scripting

Changing every other comma to point

Hi I am working with set of data which is written in Swedish format. comma is used instead of point for decimal numbers in Sweden. My data set is like this: 1,188,1,250,0,757,0,946,8,960 1,257,1,300,0,802,1,002,9,485 1,328,1,350,0,846,1,058,10,021 1,381,1,400,0,880,1,100,10,418 ... (5 Replies)
Discussion started by: Johanni
5 Replies

4. How to Post in the The UNIX and Linux Forums

Help me, write a bash script to delete parent entry with all their child entry in LDAP UNIX server

Hi All, Please help me and guide me to write a bash/shell script on Linux box to delete parent entry with all their child entries. example: Parent is : ---------- dn: email=yogesh.kumar@wipro.com, o=wipro, o=in child is: ---------- dn: cn: yogesh kumar, email=yogesh.kumar@wipro.com,... (1 Reply)
Discussion started by: Chand
1 Replies

5. Shell Programming and Scripting

How to perform a hexdump using dd from start point to end point?

hi, I would like to ask or is it possible to dump a hex using dd from starting point to end point just like the "xxd -s 512 -l 512 <bin file>" I know the redirect hexdump -C but i can't figure it out the combination options of dd. Hope someone can share their knowledge.. Thanks in... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Programming

Floating Point

Anyone help me i cant found the error of floating point if needed, i added the code complete #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> typedef struct { int hh; int mm; int ss; char nom; int punt; }cancion; typedef struct... (9 Replies)
Discussion started by: Slasho
9 Replies

7. Solaris

Neat trick: Changing the permissions of an underlying mount point

A colleague of mine showed me a neat little trick in Solaris (I would guess sol 10 but perhaps earlier versions too) that I'd not seen before and thought I'd share here in case it's new for someone else also. As most of you know, Solaris has the annoying habit of producing error messages when... (6 Replies)
Discussion started by: Smiling Dragon
6 Replies

8. Shell Programming and Scripting

Please point the error

Hi i want the output of the following code as follows: colname typename NOT NULL default current timestamp But there seems to be some problem . Kindly correct that COLNAME="colname" typename="typename" DEFAULT="current timestamp" echo "$COLNAME $TYPENAME NOT NULL... (1 Reply)
Discussion started by: skyineyes
1 Replies

9. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

10. UNIX for Advanced & Expert Users

Fibre connection Point to Point SUN

Anyone know of a guide or instructions for Solaris I got to configure a SBUS HBA to talk to a tape robot. I have done this on a switch but not point to point. just going HBA >>>>> TAPE Fibre simple two nodes Kie (6 Replies)
Discussion started by: kie
6 Replies
Login or Register to Ask a Question