Category: General C Things
C Operators
% Remainder after division (modulo division) The result of a modulo division is the remainder of an integer division of the given numbers. Examples
if
If (variable) if (some_variable) do_something; Anything that's not a 0 is a true value in if If with load of a return value into a variable if ((count = some_function()) > -1) { //count contains the return value }
State Machine
A Mode State Machine
Include
#include “..\ap-main”
Constants
‘u’ or ‘U’ to indicate an unsigned constant, like 33u ‘ul’ or ‘UL’ to indicate an unsigned long constant, like 32767ul
State ? ( ) : ( ) Ternary Operator
Usage Examples
Defines
General Define Usage Create a define: #define NUM_OF_ANODES 2 In code: #if NUM_OF_ANODES == 2 #endif #ifdef #ifndef #elif #else #endif #if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM) || defined(PIC18F_STARTER_KIT_1) Multi Line Continuation Character Use the ‘\’ backslash character at the end of each line except for the last. If you have any comments surround them with /* […]
Line Continuation Character
\ //Put a ‘\’ at the end of a line to signify to compiler next line shoud be part of this line //This is useful for defines etc, e.g.:- #define USBInitialize(x) \ { \ USBHostInit(x); \ }