# Rdoc on c and cpp files

**URL:** <https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567>\
**Category:** Ruby\
**Created:** [May 8, 2007, 12:05am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567 "2007-05-08T00:05:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 12:05am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/1 "2007-05-08T00:05:21Z")

</div>

Can I use rdoc to generate documentation for c and C++ sources? If  
so, how do I mark the comments?

/\* ??? \*/  
void main() {  
…  
}

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 12:12am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/2 "2007-05-08T00:12:22Z")

</div>

In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid), ray  
writes:

> Can I use rdoc to generate documentation for c and C++ sources? If  
> so, how do I mark the comments?

> /\* ??? \*/  
> void main() {  
> …  
> }

_AHEM_.

“int main”.

(See the comp.lang.c FAQ.)

-s

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 12:53am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/3 "2007-05-08T00:53:26Z")

</div>

In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid), John J.  
writes:

> What PS is saying is, unless you’re using a really old compiler and  
> system (really really old) …  
> main is a function that always returns int. Not void. Though some  
> compilers are kind of forgiving and will change it internally to int  
> anyway, just use int.

It’s been “int” since the first C compilers. There’s some platforms  
that are more tolerant, but it’s been that way since K&R1.

-s

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 1:13am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/4 "2007-05-08T01:13:27Z")

</div>

On May 8, 2007, at 7:51 AM, Peter S. wrote:

> -s

Perhaps it has. Doesn’t matter since when. There are and were  
compilers that accept it. There are (unfortunately) and were books  
that taught void main for a long time.  
I can only speculate that they did this to initially hide some  
details from people just starting out with C.  
Luckily it doesn’t happen anymore, but a lot of those old books are  
still floating around, not to mention old code…

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 12:48am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/5 "2007-05-08T00:48:26Z")

</div>

On May 8, 2007, at 7:11 AM, Peter S. wrote:

> _AHEM_.
> 
> “int main”.
> 
> (See the comp.lang.c FAQ.)
> 
> -s

What PS is saying is, unless you’re using a really old compiler and  
system (really really old) …  
main is a function that always returns int. Not void. Though some  
compilers are kind of forgiving and will change it internally to int  
anyway, just use int.

The answer is yes for C and I don’t know for C++  
visit:  
[http://rdoc.sourceforge.net/doc/index.html](http://rdoc.sourceforge.net/doc/index.html)

Also take a look at some of the docs generated by any gem that uses C  
code in a C file.  
This will give you plenty of info.  
Do pay close attention to the style of C used. Like styles of writing  
in human languages, C has many styles and the style used by the Ruby-  
Core commiters is the style you can expect RDOC to like best.

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 1:32am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/6 "2007-05-08T01:32:28Z")

</div>

John J. wrote:

> > 
> 
> Luckily it doesn’t happen anymore, but a lot of those old books are  
> still floating around, not to mention old code…

I know the free Borland C++ compiler accepts void main(). I always used  
it for utility programs where I didn’t care for the return from the  
program. My copy of K&R uses just main() for programs and the Borland  
compiler accepts it without any warnings.

---

<div class="post-metadata">

**Author:** ![ray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://www.ruby-forum.com/u/ray)\
**Post date:** [May 8, 2007, 2:16am UTC](https://www.ruby-forum.com/t/rdoc-on-c-and-cpp-files/103567/7 "2007-05-08T02:16:30Z")

</div>

On May 7, 7:29 pm, “Michael W. Ryder” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > > anyway, just use int.  
> > > > from people just starting out with C.  
> > > > Luckily it doesn’t happen anymore, but a lot of those old books are  
> > > > still floating around, not to mention old code…
> 
> I know the free Borland C++ compiler accepts void main(). I always used  
> it for utility programs where I didn’t care for the return from the  
> program. My copy of K&R uses just main() for programs and the Borland  
> compiler accepts it without any warnings.

I typed the question quickly and used void main without thinking much  
at all, hoping to get a quick answer to my question about rdoc.  
Didn’t think it would generate more discussions about void main and  
int main … 🙂

Ray,
