Cirrus Logic CS485 Bedienungsanleitung Seite 38

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 67
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 37
CS485G Spring 2015 38
6. Advice:
(a) Multiple compilation units should share global declarations via
a .h file.
(b) Use static if possible to prevent conflicts.
(c) Initialize global variables (to make them strong).
(d) Declare shared global variables extern.
41 Libraries
1. Lecture 22, 3/25/2015
2. C library (libc): about 4MB (static), 2MB (dynamic); about 1600
symbols; routines for I/O, memory allocation, signals, strings, ran-
dom numbers, integer mathematics.
3. Math library (libm): about 1MB; about 400 symbols; floating-point
math.
4. The linker only uses the symbols from the library that are unresolved
when it gets to that library in the command-line order, so libraries
should be listed at the end of the command line, and special libraries
(like libm) before general ones (like libc).
5. Shared libraries that are dynamically loaded reduce duplication in
executable object files and allow for quick incorporation of bug fixes.
6. Shared libraries are usually loaded into memory when a program
starts, but it is possible to load them later.
1 #include <dlfcn.h>
2 void
*
handle;
3 void (
*
addvec)(int
*
, int
*
, int
*
, int);
4 char
*
error;
5 handle = dlopen("./libvector.so", RTLD_LAZY);
6 // should verify handle != NULL
7 addvec = dlsym(handle, "addvec");
8 // should verify addvec != NULL
9 // may now invoke addvec()
10 dlclose(handle);; // should verify return value >= 0
Seitenansicht 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 66 67

Kommentare zu diesen Handbüchern

Keine Kommentare