00001 /* ///////////////////////////////////////////////////////////////////////////// 00002 * File: examples/cpp/example_c_printf/example_c_printf.c 00003 * 00004 * Purpose: C example program for Pantheios. Demonstrates: 00005 * 00006 * - use of pantheios_printf() in C compilation units 00007 * 00008 * Created: 31st August 2006 00009 * Updated: 2nd September 2006 00010 * 00011 * www: http://www.pantheios.org/ 00012 * 00013 * License: This source code is placed into the public domain 2006 00014 * by Synesis Software Pty Ltd. There are no restrictions 00015 * whatsoever to your use of the software. 00016 * 00017 * This software is provided "as is", and any warranties, 00018 * express or implied, of any kind and for any purpose, are 00019 * disclaimed. 00020 * 00021 * ////////////////////////////////////////////////////////////////////////// */ 00022 00023 00024 /* Pantheios Header Files */ 00025 #include <pantheios/pantheios.h> /* Pantheios C main header */ 00026 00027 /* Standard C Header Files */ 00028 #include <stdlib.h> /* for exit codes */ 00029 00030 /* ////////////////////////////////////////////////////////////////////////// */ 00031 00032 /* Define the fe.simple process identity, so that it links when using fe.simple */ 00033 const char FE_SIMPLE_PROCESS_IDENTITY[] = "example_c_printf"; 00034 00035 /* ////////////////////////////////////////////////////////////////////////// */ 00036 00037 int main() 00038 { 00039 /* Must initialise Pantheios, when using from C (and there are no C++ 00040 * compilation units in the link-unit). 00041 * 00042 * If this is not done, undefined behaviour will ensue ... 00043 */ 00044 if(pantheios_init() < 0) 00045 { 00046 return EXIT_FAILURE; 00047 } 00048 else 00049 { 00050 int i = 123; 00051 float f = 99.99f; 00052 00053 /* Log the int and the float: Output: "int=123, float=99.99" 00054 */ 00055 pantheios_printf( PANTHEIOS_SEV_INFORMATIONAL, "int=%d, float=%g" 00056 , i, f); 00057 00058 /* Must uninitialise Pantheios. 00059 * 00060 * pantheios_uninit() must be called once for each successful (>=0) 00061 * invocation of pantheios_init(). 00062 */ 00063 pantheios_uninit(); 00064 00065 return EXIT_SUCCESS; 00066 } 00067 } 00068 00069 /* ////////////////////////////////////////////////////////////////////////// */
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|