Thursday Jun 23, 2005

Since when do void functions return values??

I've been trying to compile GNOME 2.10 on Solaris using Forte for over  a week now, and I have to say I'm amazed at the number of times I've had to fix code that has a function that is declared to be "void" -  ie. doesn't return a value, but in the function implementation there is a line "return " - while this may compile with GCC - which surprises me in it self - it's just not correct C syntax and the Forte compiles don't tollerate it, which I think is perfectly fine.

I suppose this also works otherways - GCC has the nice feature of __FUNCTION__ being a string that's available for printf type debugging to provide useful information as to the locality of an assertion or such, but again this doesn't work in all compilers - it would be a nice feature, if it did, but the reality of the situation is that it doesn't - so please only use it if you wrap it in a #ifdef _GNUC_ / #endif.

So why is this happening, is GCC becoming like Visual Basic -- accepting things that are not strictly correct, but allow them to be used anyway? I certainly hope not. Or maybe it's just people are correctly making use of the -Wall and -Werror flags for gcc - it's certainly good practice, and if you really want to learn a language and write bug-free code it's the best way...

Maybe this is where it would be a good idea for people working in the community to use other complers.. So guys, Forte is now available for free use in conjunction with Open Solaris - so maybe this is the time to do it...

PS - I hope to get around to providing the necessary patches for the community soon to fix the one's I've come across so far...

About

dar

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
News

No bookmarks in folder

Blogroll

No bookmarks in folder