[C언어]리눅스/윈도우 호환 프로그래밍 기타 팁
~
윈도우와 리눅스 호환 프로그래밍을 작성할때 찾았던 자료들을
여러개 올려보겠습니다.
정보 공유라기보다 개인 자료정리의 의미가 더 크니, 자료를 보시고 궁금한게 있음 물어봐주세요!
~
~
1.공유 라이브러리 함수 관련 (dllexport, dllimport)
출처 : https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux
#if defined(_MSC_VER)
// Microsoft
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
// GCC
#define EXPORT __attribute__((visibility("default")))
#define IMPORT
#else
// do nothing and hope for the best?
#define EXPORT
#define IMPORT
#pragma warning Unknown dynamic link import/export semantics.
#endif
~
~
2.void far 관련
출처 : https://www.linuxquestions.org/questions/programming-9/problem-with-void-far-605368/
far는 그냥 무시하자. linux에서는 아무런 의미가 없다.
void far(windows) -> void(linux)
~
~
3. 기타 컴파일 관련
math.h 사용시 Link에 "-lm" 추가
pthread_kill 사용시 소스에 #include <signal.h> 추가
modbus.h사용시 링크에 -wl(WL의 소문자) 추가
~