sonysame 2018. 9. 27. 22:09

큐티 크리에이터 설치


(uint8_t*)thdr 대신에 

이렇게 쓰자 static_cast<uint8_t*>(thdr)


inet_ntoa


char *


static은 전역변수랑 비슷하게 컴파일되지만 visibility는 함수내에서만


thread static 변수는 thread마다 객체가 생긴다. thread마다 다르지 않으면 race condition을 일으킬 수 있다. 

하지만 생성자 혹은 소멸자가 있으면 thread static 변수는 프로그램에 부하가 커진다.


entrant 진입: 함수에 들어가는것


reentrant 재진입 


inet_ntoa는 reentrant하지 않는다. 

inet_ntop 를 사용하자



char * src=inet_ntoa(ihdr->ip_src);

char * dst=inet_ntoa(ihdr->ip_dst);

printf("%s %s하면 안된다.



#define min(A,B) ((A)<(B)?(A):(B))


C++의 template function

template <class T> const T& min (const T& a, const T& b) {
  return !(b<a)?a:b;     // or: return !comp(b,a)?a:b; for version (2)
}

min<int>(3,4)