473,383 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 2499

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********@yahoo.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*******@gmail.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********@yahoo.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.disclaimer>
_
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********@yahoo.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.disclaimer>
_
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********@yahoo.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.com, 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
CBFalconer wrote:
"Kevin D. Quitt" wrote:
CBFalconer <cb********@yahoo.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 :-)


And now I found the old URL, redownloaded it, and you omitted the
makefile!

--
"If you want to post a followup via groups.google.com, 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 #11
CBFalconer wrote:
CBFalconer wrote:
"Kevin D. Quitt" wrote:
CBFalconer <cb********@yahoo.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 :-)

And now I found the old URL, redownloaded it, and you omitted the
makefile!


My, you are one hard to satisfy customer...
Next time he will have to go for the closet in the basement ;-)
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #12

<ftp://ftp.quitt.net/c/cdecl-2.5.zip>

*sigh*
--
#include <standard.disclaimer>
_
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 #13

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

Similar topics

3
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?...
6
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...
6
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; ...
5
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...
2
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...
13
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...
48
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...
5
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.