Tuesday, September 28, 2010

How to call a function before main and after main

1. Using GCC compiler on Linux/Solaris

/*main.c :this program tells how we can call a function before main() call and after main() call*/

#include

void my_ctor (void) __attribute__ ((constructor));
void my_dtor (void) __attribute__ ((destructor));

void
my_ctor (void)
{
printf ("hello before main()\n");
}

void
my_dtor (void)
{
printf ("bye after main()\n");
}

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

$gcc main.c
$./a.out
hello before main()
hello
bye after main()


2. Using CC compiler on Solaris[Using Pragma]

Using pragma
============


#pragma init (foo)

void foo()
{
printf("\nInside foo");
}

#pragma fini (bar)

void bar()
{
printf("\nInside bar");
}

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

$cc main.c
$./a.out
Inside foo
Inside main
Inside bar

62 comments:

Anonymous said...

Just desire to say your article is as astonishing.

The clarity in your post is simply spectacular and i
could assume you're an expert on this subject. Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the rewarding work.

Here is my web site; california golf schools

Anonymous said...

I have been exploring for a little for any high quality articles or weblog posts on this sort of space .
Exploring in Yahoo I eventually stumbled upon this site.
Reading this info So i am satisfied to express that I've an incredibly just right uncanny feeling I discovered exactly what I needed. I so much no doubt will make certain to do not omit this website and give it a glance on a relentless basis.

Review my site :: Sushi Orlando

Anonymous said...

Hi my friend! I want to say that this article is
amazing, nice written and include approximately all important infos.

I'd like to look more posts like this .

Feel free to surf to my web site japanese restaurant in moorestown nj

Anonymous said...

Thanks for the marvelous posting! I really enjoyed
reading it, you might be a great author. I will make certain to bookmark your blog and will
often come back later in life. I want to encourage you to
continue your great posts, have a nice holiday weekend!



My blog post :: florist supplies miami fl

Anonymous said...

My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the expenses. But he's tryiong none the less. I've been using WordPress
on numerous websites for about a year and am worried about switching to
another platform. I have heard excellent things about
blogengine.net. Is there a way I can import all my wordpress posts into it?
Any help would be greatly appreciated!

Check out my page; http://www.boardcentralalert.sidcorporation.com

Anonymous said...

Piece of writing writing is also a fun, if you be acquainted with afterward you can write if not it
is complicated to write.

My page: Seafood Restaurant
my site :: Cheers Kissimmee

Anonymous said...

I was wondering if you ever considered changing the page layout of your site?

Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so
people could connect with it better. Youve got an awful lot
of text for only having 1 or 2 images. Maybe you could space it out better?


my weblog: physical therapist salary in florida

Anonymous said...

Hello there! This is kind of off topic but I need some guidance from an established blog.
Is it tough to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about setting up
my own but I'm not sure where to start. Do you have any ideas or suggestions? Many thanks

Check out my web blog ... las vegas golf schools butch harmon

Anonymous said...

Appreciate the recommendation. Will try it out.

my web-site :: easy-golf-tips.com

Anonymous said...

Have you ever thought about adding a little bit more than just your articles?
I mean, what you say is fundamental and everything.
Nevertheless imagine if you added some great images or video clips
to give your posts more, "pop"! Your content is excellent but with pics and videos, this website could certainly be one of the
best in its field. Superb blog!

Feel free to visit my blog post :: dirrebreather.com

Anonymous said...

Sweet blog! I found it while browsing on
Yahoo News. Do you have any tips on how to get listed in Yahoo
News? I've been trying for a while but I never seem to get there! Thank you

Stop by my blog: womens fitness swim suits

Anonymous said...

I know this if off topic but I'm looking into starting my own blog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny?
I'm not very web smart so I'm not 100% sure. Any tips or advice would be greatly appreciated. Cheers

my web page ... foursquare.com

Anonymous said...

My spouse and I absolutely love your blog and find most of your post's to be just what I'm looking
for. Would you offer guest writers to write content in your
case? I wouldn't mind writing a post or elaborating on most of the subjects you write related to here. Again, awesome web log!

Here is my website: studio 9 shoes
my web page: http://www.openbottles.com

Anonymous said...

Neat blog! Is your theme custom made or did you download it from somewhere?
A design like yours with a few simple tweeks would really make my blog jump out.
Please let me know where you got your theme. With
thanks

Here is my webpage ... digital to analog converter

Anonymous said...

I'm starting up a online website directory and was wondering if I can submit your blog? I'm trying
to grow my directory gradually by hand so that it retains quality.
I'll make sure and put your website in the best category and I'll also use,
"Blogger: My Stuff" as your anchor text. Be sure to let me know if this is ok with you by contacting me at: emilyashley@gmx.
de. Thanks

my blog post www.photographers.ie

Anonymous said...

Wow! This blog looks just like my old one!
It's on a entirely different subject but it has pretty much the same layout and design. Wonderful choice of colors!

My webpage :: ballroom dance shoes boys

Anonymous said...

Howdy just wanted to give you a quick heads up. The words
in your post seem to be running off the screen in Safari.
I'm not sure if this is a formatting issue or something to do with internet browser compatibility but I thought I'd post to let you know.
The design look great though! Hope you get the issue resolved soon.

Cheers

Check out my web-site ... Jazz dance Shoes las vegas

Anonymous said...

Exploring digg.com I noticed your website bookmarked as:
Blogger: My Stuff. I am assuming you book marked it yourself and wanted to ask
if social book-marking gets you a good deal of visitors?
I've been contemplating doing some bookmarking for a few of my sites but wasn't certain if it
would generate any positive results. Thank you so much.

my web blog; dance shoes for salsa uk

Anonymous said...

I enjoy what you guys tend to be up too. This type
of clever work and reporting! Keep up the very
good works guys I've added you guys to blogroll.

my web page rs232 to usb converter circuit diagram

Anonymous said...

Write more, thats all I have to say. Literally, it seems as though you
relied on the video to make your point. You clearly know what youre talking about, why
throw away your intelligence on just posting videos
to your site when you could be giving us something informative to read?


Take a look at my site: device driver for hp officejet 4500 desktop

Anonymous said...

I'm really inspired with your writing abilities as neatly as with the format in your weblog. Is that this a paid subject matter or did you modify it your self? Anyway stay up the nice high quality writing, it's uncommon to peer a great weblog like this
one today..

Also visit my web-site ... foofara.com

Anonymous said...

Thanks in favor of sharing such a pleasant opinion, paragraph is good,
thats why i have read it completely

Here is my blog post; golf buggy batteries perth

Anonymous said...

This is a topic that's close to my heart... Best wishes! Where are your contact details though?

My web site; http://sunrisesinthewest.org

Anonymous said...

Wow, this post is fastidious, my sister is analyzing these things,
so I am going to inform her.

My blog post - golfsmith austin used clubs

Anonymous said...

I'm curious which blogging platform you're using?

I'm new to operating a blog and have been thinking about using the Ning platform. Do you think this is a good foundation to start with? I would be extremely thankful if I could ask you some questions through email so I can learn a bit more prior to getting started. When you have some free time, please contact me at: krisisaacs@gmail.com. Kudos

Feel free to surf to my web site - short term lease apartments tampa fl

Anonymous said...

Have you ever thought about writing an e-book or guest authoring on other sites?
I have a blog centered on the same topics you discuss
and would really like to have you share some stories/information.

I know my subscribers would enjoy your work. If you are even remotely interested, feel
free to send me an e-mail.

Feel free to surf to my web site :: national corporate housing companies

Anonymous said...

Excellent post. Keep posting such kind of info
on your blog. Im really impressed by your blog.
Hello there, You've performed a great job. I'll certainly digg it and for my part
suggest to my friends. I'm sure they will be benefited from this site.

Also visit my web blog :: Commercial Led Lighting

Anonymous said...

I do not leave a response, but I browsed a few of the comments on this page "How to call a function before main and after main".
I do have some questions for you if it's okay. Is it only me or does it look like a few of these responses appear like they are left by brain dead visitors? :-P And, if you are writing at additional social sites, I'd
like to follow you. Could you list of the complete urls of your social pages like
your linkedin profile, Facebook page or twitter feed?

Here is my blog post ... Short game classes

Anonymous said...

Neat blog! Is your theme custom made or did you download it
from somewhere? A design like yours with a few simple tweeks would really make
my blog shine. Please let me know where you got your theme.
Kudos

Also visit my page ... furnished apartments pensacola beach fl

Anonymous said...

What a data of un-ambiguity and preserveness of valuable familiarity on
the topic of unexpected emotions.

Feel free to surf to my weblog ... applied kinesiology allergy testing

Anonymous said...

Hola! I've been reading your web site for some time now and finally got the bravery to go ahead and give you a shout out from New Caney Tx! Just wanted to say keep up the fantastic work!

Stop by my web blog :: Las Vegas Golf Schools

Anonymous said...

Hello! I just noticed your webpage: Blogger: My Stuff when
I was searching reddit.com. It looks as though someone enjoyed your blog so much
they decided to bookmark it. I'll definitely be coming back here more often.

Take a look at my website :: caig circuit board pen

Anonymous said...

I am really loving the theme/design of your blog.
Do you ever run into any internet browser compatibility problems?
A number of my blog visitors have complained about my website not operating correctly in Explorer
but looks great in Chrome. Do you have any solutions to help
fix this problem?

Feel free to surf to my homepage :: epoch golf tees

Anonymous said...

Hmm it seems like your site ate my first comment (it was extremely long) so I guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your blog.
I too am an aspiring blog writer but I'm still new to the whole thing. Do you have any helpful hints for beginner blog writers? I'd genuinely
appreciate it.

Visit my blog :: middle back spasms symptoms at night

Anonymous said...

Hello, I do believe your site might be having internet browser compatibility issues.

When I take a look at your blog in Safari, it looks fine however,
if opening in Internet Explorer, it's got some overlapping issues. I just wanted to give you a quick heads up! Apart from that, great website!

Also visit my webpage - Orlando Sushi

Anonymous said...

I'm not sure why but this website is loading incredibly slow for me. Is anyone else having this problem or is it a problem on my end? I'll check back
later on and see if the problem still exists.

Review my homepage: golf lessons for beginners singapore

Anonymous said...

Hello my friend! I wish to say that this article is amazing, great written and include approximately all vital infos.

I would like to look more posts like this .

my web site: www.winterparkbusinesslist.com

Anonymous said...

I enjoy what you guys are up too. Such clever work and exposure!
Keep up the good works guys I've added you guys to our blogroll.

Feel free to visit my weblog :: mueller athletic tape

Anonymous said...

Hello to all, how is everything, I think every one is getting more
from this site, and your views are pleasant in favor of new people.


Also visit my page Chiropractor

Anonymous said...

This post gives clear idea for the new people of blogging, that
genuinely how to do blogging and site-building.


Also visit my site wholisticuniverse.com

Anonymous said...

An outstanding share! I have just forwarded this
onto a friend who had been conducting a little homework on
this. And he actually ordered me dinner due to the fact that I stumbled upon it for him.
.. lol. So allow me to reword this.... Thanks for the meal!
! But yeah, thanks for spending the time to talk about this matter here on your web
site.

Visit my homepage inversion table teeter

Anonymous said...

This paragraph will help the internet visitors for building up new blog or
even a blog from start to end.

Feel free to visit my site; chiropractor-orlando.com

Anonymous said...

At this time it sounds like BlogEngine is the top blogging platform out
there right now. (from what I've read) Is that what you're using on your blog?


my page - personal injury attorney

Anonymous said...

Its such as you learn my thoughts! You appear to know a lot about this, like you wrote
the e book in it or something. I feel that you simply could do
with some % to drive the message home a bit, but other than that, that is great blog.

An excellent read. I will certainly be back.


Stop by my website: Www.Purevolume.com

Anonymous said...

This design is incredible! You obviously know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to start my own
blog (well, almost...HaHa!) Great job. I really loved what you
had to say, and more than that, how you presented it.
Too cool!

Here is my blog post golfsmith tennis

Anonymous said...

Appreciating the dedication you put into your website and detailed
information you provide. It's awesome to come across a blog every once in a while that isn't the same unwanted rehashed material.
Wonderful read! I've saved your site and I'm including your RSS feeds to my Google account.


Feel free to visit my page ... university high school

Anonymous said...

I need to to thank you for this good read!! I definitely loved every little bit of it.
I have got you book-marked to look at new things you post…

Check out my page - St Cloud Florist

Anonymous said...

I don't know if it's just me or if everyone else encountering problems with your website.
It appears like some of the text within your content are running off the screen.
Can someone else please comment and let me know if this is happening to them too?
This might be a problem with my internet browser because I've had this happen before. Cheers

Also visit my blog post: exercises after back surgery

Anonymous said...

Hello great blog! Does running a blog like this take a massive amount work?
I have very little expertise in coding however I
was hoping to start my own blog soon. Anyhow, if you have any recommendations or tips for new blog owners please
share. I understand this is off subject but I just had to ask.

Thanks!

Look into my webpage shamrock

Anonymous said...

Howdy, There's no doubt that your blog could be having browser compatibility problems. When I look at your site in Safari, it looks fine however, if opening in Internet Explorer, it has some overlapping issues. I simply wanted to provide you with a quick heads up! Besides that, fantastic website!

my blog; frigidaire refrigerators review

Anonymous said...

My partner and I stumbled over here by a different page and thought I may as well check
things out. I like what I see so now i am following you.
Look forward to going over your web page for
a second time.

My page - renovation loan options

Anonymous said...

This is the perfect web site for anybody who wishes to find out about this topic.
You understand so much its almost hard to
argue with you (not that I really would want to…HaHa).
You certainly put a fresh spin on a subject that has been written about for ages.

Excellent stuff, just excellent!

My page :: chiropractic medicine and speech

Anonymous said...

WOW just what I was searching for. Came here by searching for benefits of chiropractic care in pregnancy

Look into my blog: college pictures for Facebook

Anonymous said...

Everything is very open with a precise description of the challenges.

It was truly informative. Your website is very helpful.
Thanks for sharing!

my webpage :: appliance repair san antonio reviews

Anonymous said...

Hey there! I know this is kinda off topic but I was wondering which blog
platform are you using for this website? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at options for another platform. I would be great if you could point me in the direction of a good platform.

Also visit my website ... appliance repair business names

Anonymous said...

Its like you read my mind! You seem to know so much about this, like you wrote the book in it or
something. I think that you could do with some pics to
drive the message home a little bit, but other than that, this is excellent blog.
An excellent read. I will certainly be back.


My blog; debenhams kitchen appliances fridge freezers

Anonymous said...

Today, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a thirty foot drop, just
so she can be a youtube sensation. My apple ipad is now destroyed and she has
83 views. I know this is completely off topic but I had to share
it with someone!

Also visit my web site 24 hr appliance repairs

Anonymous said...

We have gone ahead and included a link back to your website from
one of my clients requesting it. I have used your site URL:
http://www.blogger.com/comment.g?blogID=4647272498333643717&postID=154766861674951709 and blog title:
Blogger: My Stuff to be sure you get the correct anchor text.
If you woud like to see where your website link has been placed, please contact me at:
octaviacolwell@gmail.com. Thankyou

Also visit my site - 24 hour appliance repair (http://www.purevolume.com)

Anonymous said...

Does your site have a contact page? I'm having problems locating it but, I'd
like to shoot you an e-mail. I've got some recommendations for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it develop over time.

Check out my page fridge repair

Anonymous said...

Thank you, I have just been searching for info about this topic for ages and yours is the best I've found out till now. However, what concerning the bottom line? Are you sure about the source?

my site :: golf Carts For sale in iowa

Anonymous said...

ll see much better results with this diet plan than you would with others that use some
generic formula to calculate your nutrient needs. The 62 page
Somanabolic Weight Training program that details the specific workouts you need to do depending on your somatotype (body type)
in order to pack on lean muscle mass. Then opt for ones cheapest way to help
you feed those guns while using the Egg White peptids.

my blog post ... Somanabolic Muscle Maximizer Review

Anonymous said...

Thanks in support of sharing such a nice thinking, paragraph is fastidious, thats why i
have read it fully

my blog :: symptoms of torn rotator cuff