{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

LEC20081106 - Introduction to Computer Programming November...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern