Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion grrrrr. #define should be typedef
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nicholas Clark  
View profile  
 More options Jun 11 2004, 5:50 am
Newsgroups: perl.perl6.internals
From: n...@ccl4.org (Nicholas Clark)
Date: Fri, 11 Jun 2004 10:50:43 +0100
Local: Fri, Jun 11 2004 5:50 am
Subject: grrrrr. #define should be typedef
Any reason *not* to make this change:

Index: include/parrot/string.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/string.h,v
retrieving revision 1.59
diff -d -u -r1.59 string.h
--- include/parrot/string.h     22 Apr 2004 08:55:06 -0000      1.59
+++ include/parrot/string.h     11 Jun 2004 09:46:36 -0000
@@ -54,7 +54,7 @@
 #define STRINGINFO_STRLEN   6

 /* &end_gen */
-#define STRING struct parrot_string_t
+typedef struct parrot_string_t STRING;

 #endif /* PARROT_IN_CORE */
 #endif /* PARROT_STRING_H_GUARD */

Witness the pain that using the pre-processor causes:

(gdb) down
#0  0x00034114 in char8_at (offs=12, context=0xb003f850) at src/string.c:2918
2918        return ((char*)((STRING *)context)->strstart)[offs];
(gdb) print (STRING *)context)
No symbol "STRING" in current context.

followed by swearing and cursing and time wasted grepping to find out what
a STRING is.

Is there any reason not to have a coding standard that typedef should be
used whenever possible (and non-uses must have their reason commented?)

Nicholas Clark


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.