473,750 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cdecl test cases

Did a fun project some years ago.. a cdecl, but never really tested it.

Here are some test cases I just tried:

cdecl> char **argv;
cdecl> argv is pointer to pointer to char
Looks ok

cdecl> int (*daytab)[13];
cdecl> daytab is pointer to array [13] of int
Looks ok

cdecl> int *daytab[13];
cdecl> daytab is array [13] of pointer to int
Looks ok

cdecl> void *comp();
cdecl> comp is function returning pointer to void
Looks ok

cdecl> char (*(*x())[])();
cdecl> x is function returning pointer to array of pointer to function
returning char
Looks ok

cdecl> char (*(*x[3])())[5];
cdecl> x is array [3] of pointer to function returning pointer to array
[5] of char
Looks ok

cdecl> char* const *(*next)();
cdecl> next is pointer to function returning pointer to (read-only)
pointer to char
Parse error: ";" at line 255. Hint: Not a valid type.
Looks ok, except for the parse error.

cdecl> char **(c[10])(int **p);
cdecl> c is array [10] of function returning pointer to pointer to char
Looks ok

cdecl> void (*signal(int sig, void (*func)(int)))( int);
cdecl> signal is function returning pointer to void
cdecl> void (*signal(int, void (*)(int)))(int) ;
cdecl> signal is function returning pointer to void
Not ok

Did I miss something here, or do people agree with the above?
(I don't have another cdecl to cross-check with)

Does someone have ideas for more test-cases?

--
Tor <torust AT online DOT no>
Nov 14 '05 #1
12 2535

Tor Rustad wrote:
Did a fun project some years ago.. a cdecl, but never really tested it.
Here are some test cases I just tried:

cdecl> char **argv;
cdecl> argv is pointer to pointer to char
Looks ok

cdecl> int (*daytab)[13];
cdecl> daytab is pointer to array [13] of int
Looks ok

cdecl> int *daytab[13];
cdecl> daytab is array [13] of pointer to int
Looks ok

cdecl> void *comp();
cdecl> comp is function returning pointer to void
Looks ok

cdecl> char (*(*x())[])();
cdecl> x is function returning pointer to array of pointer to function returning char
Looks ok

cdecl> char (*(*x[3])())[5];
cdecl> x is array [3] of pointer to function returning pointer to array [5] of char
Looks ok

cdecl> char* const *(*next)();
cdecl> next is pointer to function returning pointer to (read-only)
pointer to char
Parse error: ";" at line 255. Hint: Not a valid type.
Looks ok, except for the parse error.

cdecl> char **(c[10])(int **p);
cdecl> c is array [10] of function returning pointer to pointer to char Looks ok

cdecl> void (*signal(int sig, void (*func)(int)))( int);
cdecl> signal is function returning pointer to void
cdecl> void (*signal(int, void (*)(int)))(int) ;
cdecl> signal is function returning pointer to void
Not ok
My cdecl shows:

cdecl> explain void (*signal(int sig, void (*func)(int)))( int);
syntax error

I don't think the version of cdecl that I have handles multiple
identifiers in a single declaration (signal and func in this case).

cdecl> explain void (*signal(int, void (*)(int)))(int) ;
declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void

Look good.
Did I miss something here, or do people agree with the above?
(I don't have another cdecl to cross-check with)

Does someone have ideas for more test-cases?
The version I have is very capable and featureful and supports readline
if you have it. It was written for Linux but should be easy to port to
similiar systems. You can download the source code package, which
comes with a mini test quite, at:
http://www.ibiblio.org/pub/Linux/dev...ecl-2.5.tar.gz.
--
Tor <torust AT online DOT no>


Rob Gamble

Nov 14 '05 #2
Tor Rustad wrote:

Did a fun project some years ago.. a cdecl, but never really tested it.

Here are some test cases I just tried:

cdecl> char **argv;
cdecl> argv is pointer to pointer to char
Looks ok

cdecl> int (*daytab)[13];
cdecl> daytab is pointer to array [13] of int
Looks ok

cdecl> int *daytab[13];
cdecl> daytab is array [13] of pointer to int
Looks ok

cdecl> void *comp();
cdecl> comp is function returning pointer to void
Looks ok

cdecl> char (*(*x())[])();
cdecl> x is function returning pointer to array of pointer to function
returning char
Looks ok

cdecl> char (*(*x[3])())[5];
cdecl> x is array [3] of pointer to function returning pointer to array
[5] of char
Looks ok

cdecl> char* const *(*next)();
cdecl> next is pointer to function returning pointer to (read-only)
pointer to char
Parse error: ";" at line 255. Hint: Not a valid type.
Looks ok, except for the parse error.

cdecl> char **(c[10])(int **p);
cdecl> c is array [10] of function returning pointer to pointer to char
Looks ok

cdecl> void (*signal(int sig, void (*func)(int)))( int);
cdecl> signal is function returning pointer to void
cdecl> void (*signal(int, void (*)(int)))(int) ;
cdecl> signal is function returning pointer to void
Not ok

Did I miss something here, or do people agree with the above?
(I don't have another cdecl to cross-check with)

Does someone have ideas for more test-cases?


Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))( int);
explain void (*signal(int, void (*)(int)))(int) ;
--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

Nov 14 '05 #3
"CBFalconer " <cb********@yah oo.com> wrote in message

<snip>
Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))( int);
explain void (*signal(int, void (*)(int)))(int) ;


Thanks! Does

explain char **(c[10])(int **);

also give a parse error?

--
Tor <torust AT online DOT no>

Nov 14 '05 #4
"tigervamp" <rg*******@gmai l.com> wrote in message

<snip>
My cdecl shows:

cdecl> explain void (*signal(int sig, void (*func)(int)))( int);
syntax error

I don't think the version of cdecl that I have handles multiple
identifiers in a single declaration (signal and func in this case).
Right, IMHO that would be useful for cdecl to handle.
cdecl> explain void (*signal(int, void (*)(int)))(int) ;
declare signal as function (int, pointer to function (int) returning
void) returning pointer to function (int) returning void

Look good.
Yup, agreed.
Does someone have ideas for more test-cases?


The version I have is very capable and featureful and supports

readline if you have it.
Windows box here, which lack readline, yacc and flex!!
It was written for Linux but should be easy to port to
similiar systems. You can download the source code package, which
comes with a mini test quite, at:
http://www.ibiblio.org/pub/Linux/dev...ecl-2.5.tar.gz.


Took a look at the package, and it was far more advanced than my
little C utility (850 lines of yacc code vs 200 lines of C parser code).
For now, I only want to get 'explain' working with C89 (and C99).

I see one main thing for me to add then, and that is to parse/display
the argument list of functions... <g>

--
Tor <torust AT online DOT no>

Nov 14 '05 #5
Tor Rustad wrote:

"CBFalconer " <cb********@yah oo.com> wrote in message

<snip>
Here are the results on my system

[1] c:\c\junk>cdecl cdecl.c
declare argv as pointer to pointer to char
declare daytab as pointer to array 13 of int
declare daytab as array 13 of pointer to int
declare comp as function returning pointer to void
declare x as function returning pointer to array of pointer to
function returning char
declare x as array 3 of pointer to function returning pointer to
array 5 of char
declare next as pointer to function returning pointer to const
pointer to char
parse error
parse error
declare signal as function (int, pointer to function (int)
returning void) returning pointer to function (int) returning void

[1] c:\c\junk>cat cdecl.c
explain char **argv;
explain int (*daytab)[13];
explain int *daytab[13];
explain void *comp();
explain char (*(*x())[])();
explain char (*(*x[3])())[5];
explain char* const *(*next)();
explain char **(c[10])(int **p);
explain void (*signal(int sig, void (*func)(int)))( int);
explain void (*signal(int, void (*)(int)))(int) ;


Thanks! Does

explain char **(c[10])(int **);

also give a parse error?


[1] c:\dnld\scratch >explain char **(c[10])(int **);
declare c as array 10 of function (pointer to pointer to int)
returning pointer
to pointer to char

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

Nov 14 '05 #6
Version 2.5 source, test cases, and executable for Winblows:

<ftp://ftp.quitt.net/C/cdecl.zip>
--
#include <standard.discl aimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 14 '05 #7
"Kevin D. Quitt" wrote:

Version 2.5 source, test cases, and executable for Winblows:

<ftp://ftp.quitt.net/C/cdecl.zip>


Minor detail - that has been zipped with something outlandish, and
neither unzip (info-zip 5.51) nor pkunzip (katz 2.50) can extract
it.

--
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
Nov 14 '05 #8
On Wed, 23 Mar 2005 05:05:29 GMT, CBFalconer <cb********@yah oo.com> wrote:
Minor detail - that has been zipped with something outlandish, and
neither unzip (info-zip 5.51) nor pkunzip (katz 2.50) can extract
it.


My apologies. I used PKZIP originally; rezipped with gnu zip 2.3.
--
#include <standard.discl aimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 14 '05 #9
"Kevin D. Quitt" wrote:
CBFalconer <cb********@yah oo.com> wrote:
Minor detail - that has been zipped with something outlandish, and
neither unzip (info-zip 5.51) nor pkunzip (katz 2.50) can extract it.


My apologies. I used PKZIP originally; rezipped with gnu zip 2.3.


Of course you snipped the URL, so now I don't know where to go for
it any more :-)

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6332
by: ThinkRS232 | last post by:
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up? Following is the specific. Win32 DLL Declaration for function in MyDLL.dll extern "C" int WINAPI SpecialTimerFunction(int Val, int (*Callback)(int InVal)) C# Declaration public class MyClass
6
2396
by: ReinhardH | last post by:
Hi, I have to use a cdecl dll (3 party dll). One of the functions needs a callback as a parameter. Unfortunately it seems that I'm not able to solve this issue. What I have done is: Declare the callback as Public Delegate Sub CallbackFunction(ByVal s1 As structure1, ByVal s2 as Structure2)
6
2221
by: James Brown [MVP] | last post by:
Hi, I am having trouble understanding how the 'const' modifier affects the 'left-right' rule when deciphering c-declarations: const int *x; // x is a pointer to a 'const int' int const *x; // ?? these are the same, right? in this case the basetype is 'const int' ? int * const x = 0; // x is a const-pointer to int
5
1960
by: richard.wm.jones | last post by:
I'm trying to track down the original authors of cdecl. cdecl was dropped from Fedora Core a few years ago because of licensing concerns. The original postings to comp.sources.unix (vols 6 & 14 in 1986 and 1988 respectively) have no licensing information. In order to get cdecl back in we would need a definitive statement from key original authors that the code can be distributed under a free license (eg. GPL or BSD-style licenses, or...
2
2932
by: Udi | last post by:
Hi All, I have a C dll exporting the following: ```````````````````````````````````````````````````` typedef void (__cdecl *pCallBack)(int i); int __cdecl Foo(pCallBack pFunc); I have written an interop dll:
13
5055
by: shanti | last post by:
hi, I know that this may not be the question has to be raised in this group. in comp.lang.c FAQ list · Question 1.21 i read about cdecl . i am working with "turbo c" on a windows xp mechine. can any one provide link where i can get the compatable cdecl. i tryed but i could not found it in google search. please help me. thanks to the group and members. regards, prasanth.
48
2503
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but from what limited exposure I've had, they are pricey, reasonably buggy, and require compiler/target adaptation. Out of my frustration with two out of two of them came my own. Its instrumentation approach is based solely on profound abuse of the C
5
2974
by: Amandil | last post by:
Hi, all. I know this is not standard C, but I see the word cdecl used as a type qualifier (?) in external declarations - including the standard headers - and I'd like to know what it means (and how they it's used). It is, as far as I know, an extension to std C by several compilers. (Some use __cdecl instead, which is allowed by the standard.) This may be off-topic on clc because it's not standard, but I believe an extension that is...
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9394
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.