Welcome, Guest. Please login or register.

Author Topic: sizeof (*VarPtr) possible ?  (Read 5314 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline koaftder

  • Hero Member
  • *****
  • Join Date: Apr 2004
  • Posts: 2116
    • Show all replies
    • http://koft.net
Re: sizeof (*VarPtr) possible ?
« on: January 30, 2007, 10:09:45 PM »
Quote


#define SIZEOF(t) ((long)((&(t))+1) - (long)(&(t)))

behaves about as well as sizeof(). Of course, it doesnt handle arrays properly or handle SIZEOF(TypeName) at all ;-)



/me vomits
 

Offline koaftder

  • Hero Member
  • *****
  • Join Date: Apr 2004
  • Posts: 2116
    • Show all replies
    • http://koft.net
Re: sizeof (*VarPtr) possible ?
« Reply #1 on: January 31, 2007, 01:15:31 AM »
Quote

I make no secret of the fact I regard C++ as utterly superior to C. Not because of the OO features per se (which I do like of course) but simply because it provides much cleaner ways of doing things that in C you would otherwise end up using the preprocessor or other contrivances for. It also provides greater error checking and general robustness and last but not least, still allows you to do things low level when you need to.


Amen brother! A lot of what I do microcontroller wise is straight C, and my other projects are mostly procedural, but I really appreciate stuff from C++ land that makes my life easier, even though i don't usually do OOP unless i'm doing an MFC app, c++ stuff thats not OOP makes life easier for the C programmer.