Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Rusty's mes...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 20 of 22 Topic 26077 of 26959
Post > Topic >>

Re: Rusty's message to C++ programmers (C or C++)

by "Chris Thomasson" <cristom@[EMAIL PROTECTED] > May 6, 2008 at 12:06 AM

"cr88192" <cr88192@[EMAIL PROTECTED]
> wrote in message 
news:51475$481ff7ff$ca83b482$3400@[EMAIL PROTECTED]
>
> "Chris Thomasson" <cristom@[EMAIL PROTECTED]
> wrote in message 
> news:_eadnWL1xbc8EILVnZ2dnUVZ_j2dnZ2d@[EMAIL PROTECTED]
>> "Raz" <osjdf@[EMAIL PROTECTED]
> wrote in message 
>> news:715v141f46a5eg638h45f6tu2pem1hohh1@[EMAIL PROTECTED]
>>>
>>> On Wed, 30 Apr 2008 21:54:37 GMT, Erik Wikströ
>>>
>>>>Obviously his knowledge of C++ is not as good as it should be.
>>>
>>> As I said, I will find the link again. His knowledge of C++ is just
>>> fine.
>>>
>>>
http://www.builderau.com.au/video/soa/Rusty-s-message-to-C-programmers/0,2000064338,22432924p,00.htm
>>>
>>>
http://www.builderau.com.au/video/soa/Why-C-remains-relevant/0,2000064338,22432921p,00.htm
>>>
>>> So here is an expert of who believes that you don't need C++ to
>>> program low level. C++ brings extra complexity that is not needed.
>>
>> [...]
>>
>> You are not forced to use "all" the features of C++. One could most 
>> certainly use C++ in a kernel. However, I personally would avoid 
>> exceptions and global ctor/dtors like the plague. I also would not use 
>> the STL, oh well...
>
> one has to give up many of the features, and is still faced with many of

> the other technical issues, that IMO one is better off just using C...

Use all POD's, no ctor/dtor/"AUTO-vtable":

struct [kobject_name_POD] {
  [state];

  void ctor() {
  }

  void dtor() throw() {
  }

  [kobject_name_POD_API];
};


Think in terms of:


http://groups.google.com/group/comp.lang.c/browse_frm/thread/1b106926ba5db19f

convert that C code into simple C++ interface... POD and ASM can be used
in 
a Kernel.


Use only explicit C++ POD, __NO__ STL, exceptions, constructor,
destructors, 
virtual functions, inheritance, whatever... Every object is POD; ctor/dtor

is explicit. POD templates would be allowed. You can still benefit from
the 
syntax of the language - kernel unfriendly features.

Each POD can be initalized like:

struct Kernel_atomic_word {
  atomic_word m_value;


#define KERNEL_ATOMIC_WORD_STATICINIT(mp_value) { \
  (mp_value) \
}


  void ctor(atomic_word const value) {
    m_value = value;
  }


  void dtor() throw() {}


  // fetch-and-add
  atomic_word faa_mbacq(atomic_word const addend) throw() {
    atomic_word const result = ATOMIC_FAA(&m_value, addend);
    MEMBAR_ACQUIRE();
    return result;
  }

  atomic_word faa_mbrel(atomic_word const addend) throw() {
    MEMBAR_RELEASE();
    return ATOMIC_FAA(&m_value, addend);
  }


  // swap
  atomic_word swp_mbacq(atomic_word const value) throw() {
    atomic_word const result = ATOMIC_SWP(&m_value, addend);
    MEMBAR_ACQUIRE();
    return result;
  }

  atomic_word swp_mbrel(atomic_word const value) throw() {
    MEMBAR_RELEASE();
    return ATOMIC_SWP(&m_value, addend);
  }
};



Of course, C is nice... See, you can do "crude" OOP in C:'

http://groups.google.com/group/comp.lang.c/browse_frm/thread/1b106926ba5db19f


;^)


Humm, well, it every abstract interface has a vtable, yet their all POD...

Humm... Could possibly useful in a Kernel environment.

Indeed...

One can use C/C++ syntax in 
(POD+someASM+OOP)-(exceptions+ctor/dtor+virtual_func) in a Kernel...
 




 22 Posts in Topic:
Rusty's message to C++ programmers (C or C++)
Raz <osjdf@[EMAIL PROT  2008-05-05 18:23:50 
Re: Rusty's message to C++ programmers (C or C++)
Ian Collins <ian-news@  2008-05-06 10:27:14 
Re: Rusty's message to C++ programmers (C or C++)
Razi<lsdop@[EMAIL PROT  2008-05-05 18:52:48 
Re: Rusty's message to C++ programmers (C or C++)
"Peter Duniho"   2008-05-05 16:40:04 
Re: Rusty's message to C++ programmers (C or C++)
Razii <erterte@[EMAIL   2008-05-05 22:34:43 
Re: Rusty's message to C++ programmers (C or C++)
CBFalconer <cbfalconer  2008-05-05 20:19:18 
Re: Rusty's message to C++ programmers (C or C++)
Razii <drter@[EMAIL PR  2008-05-05 22:23:39 
Re: Rusty's message to C++ programmers (C or C++)
CBFalconer <cbfalconer  2008-05-05 22:57:19 
Re: Rusty's message to C++ programmers (C or C++)
"Mike Schilling"  2008-05-05 20:51:12 
Re: Rusty's message to C++ programmers (C or C++)
Razi <lsajdf@[EMAIL PR  2008-05-06 00:29:59 
Re: Rusty's message to C++ programmers (C or C++)
"Mike Schilling"  2008-05-05 23:37:03 
Re: Rusty's message to C++ programmers (C or C++)
Razii <hjgj@[EMAIL PRO  2008-05-06 03:34:45 
Re: Rusty's message to C++ programmers (C or C++)
Keith Thompson <kst-u@  2008-05-06 00:55:40 
Re: Rusty's message to C++ programmers (C or C++)
santosh <santosh.k83@[  2008-05-06 14:25:45 
Re: Rusty's message to C++ programmers (C or C++)
Razii <gjtrsds@[EMAIL   2008-05-07 02:01:21 
Re: Rusty's message to C++ programmers (C or C++)
"Chris Thomasson&quo  2008-05-05 23:36:50 
Re: Rusty's message to C++ programmers (C or C++)
"Chris Thomasson&quo  2008-05-06 00:07:34 
Re: Rusty's message to C++ programmers (C or C++)
"Chris Thomasson&quo  2008-05-05 15:46:18 
Re: Rusty's message to C++ programmers (C or C++)
"cr88192" <c  2008-05-06 16:06:07 
Re: Rusty's message to C++ programmers (C or C++)
"Chris Thomasson&quo  2008-05-06 00:06:17 
Re: Rusty's message to C++ programmers (C or C++)
brad <byte8bits@[EMAIL  2008-05-06 10:38:20 
Re: Rusty's message to C++ programmers (C or C++)
"Mike Schilling"  2008-05-06 22:26:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 16:13:44 CDT 2008.