LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2008, 04:24 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
Multi entry points in C program


Hi group,

I have a stupid question.

I want to make multiple entry points to a C function, simular to
symbolic links for files. No real need just want to cut down my typing
while using the debugger.

I tried this but it did not work:
Code:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 int E();
 struct  timeval   Timer;
 struct  tm        Time;
#define TIME() \
  gettimeofday( &Timer, '\0' );               \
  localtime_r(  &Timer.tv_sec, &Time );       \
  fprintf( stderr,                            \
            "%.2d:%.2d:%.2d.%.3d %s:%d \n",   \
	    (int) Time.tm_hour,               \
	    (int) Time.tm_min,                \
	    (int) Time.tm_sec,                \
	    (int) Timer.tv_usec/1000,         \
             __FILE__,__LINE__ );
int main(int argc, char *argv[] ) {
  TIME();
int E() {
  system("/bin/sleep 2");
  TIME();
  return ; } }
 
Old 08-11-2008, 04:30 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
No can do. The C runtime is called before main(), and then branches to main.

What are trying to accomplish?
 
Old 08-11-2008, 04:34 PM   #3
aleTT
LQ Newbie
 
Registered: Jul 2008
Location: Italy
Distribution: Debian Sid
Posts: 12

Rep: Reputation: 0
I think he wants to define and at the same time call the function E().
Is it right ?
 
Old 08-11-2008, 04:59 PM   #4
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
I am being lazy while using the debugger and don't want to type
'b at_this_very_long_function_name'
but rather just type
'b E'
.
Not all that important.
 
Old 08-11-2008, 06:00 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Code:
#include <stdio.h>


void this_is_my_very_very_long_function_name_that_i_dont_want_to_type_but_dont_want_to_rename()
{ fprintf(stderr, "very long function name for very short function\n"); }

void E() __attribute__ ((alias ("this_is_my_very_very_long_function_name_that_i_dont_want_to_type_but_dont_want_to_rename")));

int main()
{ E(); }
ta0kira
 
Old 08-11-2008, 06:08 PM   #6
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
comment removed

Last edited by ErV; 08-11-2008 at 06:12 PM.
 
Old 08-11-2008, 06:47 PM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
The debugger allows you to create aliases, and provides command and function name completion for you. Configure it any way you want.
 
Old 08-12-2008, 06:01 AM   #8
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
That did it

Quote:
Originally Posted by ta0kira View Post
Code:
#include <stdio.h>


void this_is_my_very_very_long_function_name_that_i_dont_want_to_type_but_dont_want_to_rename()
{ fprintf(stderr, "very long function name for very short function\n"); }

void E() __attribute__ ((alias ("this_is_my_very_very_long_function_name_that_i_dont_want_to_type_but_dont_want_to_rename")));

int main()
{ E(); }
ta0kira
Thanks, William.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DHS using p690 AIX at passport entry points? as400 AIX 0 08-10-2008 01:05 PM
need help for linux forwarding and netfilter entry points sastrym1 Linux - Kernel 0 05-15-2006 03:29 AM
DNS entry points to 2 IP's ANU Linux - General 1 01-16-2006 10:58 AM
C++ password-protected entry into program J_K9 Programming 3 07-12-2005 01:11 AM
Good program for plotting points on a map? Electrode Linux - Software 0 05-30-2004 02:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration