0

I want to acquire the address of label1 in function main without calling function Func(int a,int b). How can this be done?

Code:

File1.c

int *ptr2;
int Func(int a, int b)
{
    int c;
    c = a+b;
    label1:
    ptr = (int*)&&label1;
    return c;
}

File2.c

#include<File1.c>
extern int *ptr2; 
int main()
{
    int *ptr,var;
    //var = Func(10,20);
    ptr = ptr2; 
}
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
  • There is no portable way of doing this (indeed, `&&` is a [compiler-specific language extension](https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html)). Why do you need to? – Oliver Charlesworth Jun 23 '14 at 07:10
  • i want to get the address of a label so that i can find the size of a function. By placing a label at the end of function and then subtracting it with address given to start of a function. – user2988694 Jun 23 '14 at 07:12
  • @perreal yes you are right i want to find the length of function in bytes – user2988694 Jun 23 '14 at 07:19

0 Answers0