I am trying to understand usage of keyword __attribute in C
I have checked following two pages
http://unixwiz.net/techtips/gnu-c-attributes.html
and this page also
http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html
but still I could not understand where do I declare them and how I can use __attribute in my program.

To test this I wrote a C program but I am not able to understand how will I use attribute keyword of C in it

#include<stdio.h>
int myfunction (int ,int)
int main ()
{
 int a,b,c;
 printf("Enter 2 numbers \n");
 scanf("%d,%d",&a,&b);
 c = myfunction(a,b);
 printf("the result is %d ",c);
 exit 0;
}

int myfunction (int a,int b)
{
 int c;
return c=a+b;
}

Here's an example of creating a packed structure using attribute

struct mystr
{
char ca;
unsigned int i;
}__attribute__((packed)) thestr;

I am trying to understand usage of keyword __attribute in C
I have checked following two pages
http://unixwiz.net/techtips/gnu-c-attributes.html
and this page also
http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html
but still I could not understand where do I declare them and how I can use __attribute in my program.

To test this I wrote a C program but I am not able to understand how will I use attribute keyword of C in it

#include<stdio.h>
int myfunction (int ,int)
int main ()
{
 int a,b,c;
 printf("Enter 2 numbers \n");
 scanf("%d,%d",&a,&b);
 c = myfunction(a,b);
 printf("the result is %d ",c);
 exit 0;
}

int myfunction (int a,int b)
{
 int c;
return c=a+b;
}

Check out the explanations under this link

Remember one thing when you use these: These are compiler dependent and your code might become non portable.

This article has been dead for over six months. Start a new discussion instead.