The PI-API is built as a C/C++ library, but all function definitions and exports are ANSI C compatible. Thus, programs built with the PI-API may be compiled as C code. There is no assumption of compiler version, but it has only been tested with Microsoft compilers. The includes, libraries, paths, and preprocessor macros for compiling PI-API programs are discussed below.
Certain predefined constants are required for successful programming with the PI-API. Each compiler may automatically define some of these macros and also provide a means to define additional constants. These defines must be included in your source before the PI-API header files are included.
For this platform the required PI-API preprocessor constants are:
All Windows, both Win32 and Win64. This is defined by Microsoft compilers automatically.
Define for 32-bit and 64-bit Windows applications.
Defined for 64-bit Windows applications. This is defined by Microsoft compilers automatically.
Define for 64-bit Windows applications. This must be defined for pidefs.h.
For use in projects, makefiles and scripts, the PI-API installation defines
installation path environment variables for both the 32 and 64-bit
distributions. These are
PIHOME for the 32-bit and
PIHOME64 for the 64-bit installation. These are only defined at installation.
The include path for the PIAPI headers using these definitions is
/I $(PIHOME)\includefor 32-bit applications.
/I $(PIHOME64)\includefor 64-bit applications.
Use struct member alignment of 8 bytes
piapix.h. Additional include files are supplied that assist in making code more readable. These define error constants in
pistatus.h, and system digital state values in
The linker needs the path and import library to create an executable:
/LIBPATH:$(PIHOME)/libraryfor 32-bit applications.
piapi32.libfor 32-bit applications.
/LIBPATH:$(PIHOME64)/libraryfor 64-bit applications.
piapi.libfor 64-bit applications.
An example program and project,
apisnap.c, are provided in the directory
PIHOME\EXAMPLES\C. The makefile is a Visual C++ project makefile which builds
a program that obtains the current value for a tag. If you are developing in
MSVC, it is useful to review this program and the compiler settings
established by the project.