By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 839 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

C Macros

P: 1
Hi all,

I'm working on an assignment where I have to implement a try/finally using C macros. The assignment should be able to work as follows:

void foo() {

Expand|Select|Wrap|Line Numbers
  1.        try_point       tp1;
  2.  
  3.         ...
  4.         try (tp1) {
  5.                 /* try-body */
  6.         }
  7.         finally (tp1) {
  8.                 /* finally-body */
  9.  
  10.                 /* This is always executed.
  11.                    It is done after "body" following normal termination,
  12.                    and before continuing an "unwind".
  13.                 */
  14.         }
  15.         end_try (tp1);
  16.         ...
  17. }
We're supposed to define macros for try and finally, and try_point is a typedef. The underlying data structure is a linked list. I'm not sure how to even begin defining a macro with nested bodies like the code above suggests. Could somebody please set me in the right direction (hopefully with an example)?

thank you.
Mar 16 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.