LEC20081106 - Introduction to Computer Programming November...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Computer Programming November 6, 2008 CSC180 Fall 2008, University of Toronto
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#error directives An #error directive halts compilation of a source file and produces an error message. Example: /* stack.h */ #define MAXVAL 50 /* max depth of val stack */ void push(double); double pop(void); /* stack.c */ #include <stdio.h> #include "stack.h" CSC180 Fall 2008, University of Toronto 1
Background image of page 2
#if MAXVAL < 100 || MAXVAL % 10 != 0 #error MAXVAL must be at least 100 and a multiple of 10. #endif static int sp = 0; /* next free stack position */ static double val[MAXVAL]; /* value stack */ Example: /* from PuTTY */ int run_timers(long anow, long *next) { struct timer *first; init_timers(); #ifdef TIMING_SYNC /* * In this ifdef I put some code which deals with the * possibility that ‘anow’ disagrees with GETTICKCOUNT by a * significant margin. Our strategy for dealing with it differs * depending on platform, because on some platforms CSC180 Fall 2008, University of Toronto 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* GETTICKCOUNT is more likely to be right whereas on others * ‘anow’ is a better gold standard. */ { long tnow = GETTICKCOUNT(); if (tnow + TICKSPERSEC/50 - anow < 0 || anow + TICKSPERSEC/50 - tnow < 0 ) { #if defined TIMING_SYNC_ANOW /* * If anow is accurate and the tick count is wrong, * this is likely to be because the tick count is * derived from the system clock which has changed (as * can occur on Unix). Therefore, we resolve this by * inventing an offset which is used to adjust all
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

LEC20081106 - Introduction to Computer Programming November...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online