Örnek
Şöyle yaparız.
Şöyle yaparız.
#include <iostream>
int main(){
int i = 0;
std::cout << __builtin_clz(0) << std::endl;
}
#include <iostream>
int main(){
int i = 0;
std::cout << __builtin_clz(0) << std::endl;
}
The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable
struct __attribute__((__packed__)) BitsField
{
// Logic values
uint8_t vesselPresenceSw: 1;
uint8_t drawerPresenceSw: 1;
uint8_t pumpState: 1;
uint8_t waterValveState: 1;
uint8_t steamValveState: 1;
uint8_t motorDriverState: 1;
// Unused
uint8_t unused_0: 1;
uint8_t unused_1: 1;
};
Örnek - Cstruct packet {
uint16_t mfg;
uint8_t type;
uint16_t devid;
} __attribute__((packed));
Örnek - 1 Byte#include<stdio.h>
/* Apply the constructor attribute to myStartupFun() so that it
is executed before main() */
void myStartupFun (void) __attribute__ ((constructor));
/* Apply the destructor attribute to myCleanupFun() so that it
is executed after main() */
void myCleanupFun (void) __attribute__ ((destructor));
/* implementation of myStartupFun */
void myStartupFun (void)
{
printf ("startup code before main()\n");
}
/* implementation of myCleanupFun */
void myCleanupFun (void)
{
printf ("cleanup code after main()\n");
}
int main (void)
{
printf ("hello\n");
return 0;
}
Örnekint main(void)
{
...;
}
__attribute__ ((destructor)) void after_main(void)
{
...
}
-fvisibility=hidden
destructorclass __attribute__ ((visibility ("hidden"))) Foo{
...
};
packed