?? sh1.c
字號:
/* This is part of the shared library ld test. This file becomes part of a shared library. *//* This variable is supplied by the main program. */#ifndef XCOFF_TESTextern int mainvar;#endif/* This variable is defined in the shared library, and overridden by the main program. */#ifndef XCOFF_TESTint overriddenvar = -1;#endif/* This variable is defined in the shared library. */int shlibvar1 = 3;/* This variable is defined by another object in the shared library. */extern int shlibvar2;/* These functions return the values of the above variables as seen in the shared library. */#ifndef XCOFF_TESTintshlib_mainvar (){ return mainvar;}#endif#ifndef XCOFF_TESTintshlib_overriddenvar (){ return overriddenvar;}#endifintshlib_shlibvar1 (){ return shlibvar1;}intshlib_shlibvar2 (){ return shlibvar2;}/* This function calls a function defined by another object in the shared library. */extern int shlib_shlibcalled ();intshlib_shlibcall (){ return shlib_shlibcalled ();}/* This function calls a function defined by the main program. */#ifndef XCOFF_TESTextern int main_called ();intshlib_maincall (){ return main_called ();}#endif/* This function is passed a function pointer to shlib_mainvar. It confirms that the pointer compares equally. */int shlib_checkfunptr1 (p) int (*p) ();{ return p == shlib_shlibvar1;}/* This function is passed a function pointer to main_called. It confirms that the pointer compares equally. */#ifndef XCOFF_TESTintshlib_checkfunptr2 (p) int (*p) ();{ return p == main_called;}#endif/* This function returns a pointer to shlib_mainvar. */int(*shlib_getfunptr1 ()) (){ return shlib_shlibvar1;}/* This function returns a pointer to main_called. */#ifndef XCOFF_TESTint(*shlib_getfunptr2 ()) (){ return main_called;}#endif/* This function makes sure that constant data and local functions work. */#ifndef __STDC__#define const#endifstatic int i = 6;static const char *str = "Hello, world\n";intshlib_check (){ const char *s1, *s2; if (i != 6) return 0; /* To isolate the test, don't rely on any external functions, such as strcmp. */ s1 = "Hello, world\n"; s2 = str; while (*s1 != '\0') if (*s1++ != *s2++) return 0; if (*s2 != '\0') return 0; if (shlib_shlibvar1 () != 3) return 0; return 1;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -