Hello everyone,
I'm updating some documents that describes so many C/C++
functions/method(about 2500).
But I'm not familiar with these codes. So I want to find such a utility
can generate returning value list from the codes.
Is it possible? Or is it hard to write one?
Thanks. 17 1935 bi********@gmail.com (in 11**********************@75g2000cwc.googlegroups.c om) said:
| I'm updating some documents that describes so many C/C++
| functions/method(about 2500).
| But I'm not familiar with these codes. So I want to find such a
| utility can generate returning value list from the codes.
| Is it possible? Or is it hard to write one?
Consider just one possible function:
double binjobster_div(double a, double b)
{ return a/b;
}
I think I'll let you answer your own question. :-)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA http://www.iedu.com/DeSoto
I'm sorry I forgot to mention that all the code here returns the same
type. Let's say it's a predefined enumeration. So we won't get float or
double.
Morris Dovey wrote:
bi********@gmail.com (in 11**********************@75g2000cwc.googlegroups.c om) said:
| I'm updating some documents that describes so many C/C++
| functions/method(about 2500).
| But I'm not familiar with these codes. So I want to find such a
| utility can generate returning value list from the codes.
| Is it possible? Or is it hard to write one?
Consider just one possible function:
double binjobster_div(double a, double b)
{ return a/b;
}
I think I'll let you answer your own question. :-)
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA http://www.iedu.com/DeSoto bi********@gmail.com wrote:
Please don't top-post or quote signatures, corrected.
Morris Dovey wrote:
>>bi********@gmail.com (in 11**********************@75g2000cwc.googlegroups .com) said:
| I'm updating some documents that describes so many C/C++ | functions/method(about 2500). | But I'm not familiar with these codes. So I want to find such a | utility can generate returning value list from the codes. | Is it possible? Or is it hard to write one?
Consider just one possible function:
double binjobster_div(double a, double b) { return a/b; }
I think I'll let you answer your own question. :-)
I'm sorry I forgot to mention that all the code here returns the same
type. Let's say it's a predefined enumeration. So we won't get float or
double.
So what do you want to find? Are you trying to predict what the
functions return?
--
Ian Collins.
Ian Collins wrote:
bi********@gmail.com wrote:
Please don't top-post or quote signatures, corrected.
Morris Dovey wrote:
>bi********@gmail.com (in 11**********************@75g2000cwc.googlegroups. com) said:
| I'm updating some documents that describes so many C/C++ | functions/method(about 2500). | But I'm not familiar with these codes. So I want to find such a | utility can generate returning value list from the codes. | Is it possible? Or is it hard to write one?
Consider just one possible function:
double binjobster_div(double a, double b) { return a/b; }
I think I'll let you answer your own question. :-)
I'm sorry I forgot to mention that all the code here returns the same
type. Let's say it's a predefined enumeration. So we won't get float or
double.
So what do you want to find? Are you trying to predict what the
functions return?
--
Ian Collins.
I'm sorry I'm a newbie on news group.
Functions may call another function like below:
RTCODE foo1(TYPE1 a1, TYPE2 a2)
{
if (cond1)
return foo2(...);
else if (cond2)
return foo3(...);
return ERROR_NONE;
}
RTCODE foo2(TYPE1 a1, TYPE2 a2)
{
....
return ERROR_OUT_OF_MEMORY;
}
And reading code to list all the return values of foo1() is time
consuming, so I ask for a utility can do the job automatically.
<bi********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I'm sorry I forgot to mention that all the code here returns the same
type. Let's say it's a predefined enumeration. So we won't get float or
double.
long long binjobster_div(long long a, long long b)
{ return a/b;
}
There are 3.4e+38 different inputs and 18446744073709551616 different
outputs (unless long long is bigger than 64 bits, in which case it is more).
I guess that you are not patient to enumerate them all, especially since
18446744073709551616 or so combinations result in a trap representation.
I doubt if anyone has the patience or lifespan to complete the task. We
could use the internet, but I doubt if the answer to the question is worth
the bother, since a moment's thought will show us what the answers can be.
In addition, on some machines, int is 64 bits.
I generally try to exhaustively test functions. But when the total bytes of
input (after dereferencing pointers) exceeds 4, I generally switch to
probability based approaches ( along with endpoint tests and other extreme
conditions ). bi********@gmail.com wrote:
>
I'm sorry I'm a newbie on news group.
Functions may call another function like below:
RTCODE foo1(TYPE1 a1, TYPE2 a2)
{
if (cond1)
return foo2(...);
else if (cond2)
return foo3(...);
return ERROR_NONE;
}
RTCODE foo2(TYPE1 a1, TYPE2 a2)
{
....
return ERROR_OUT_OF_MEMORY;
}
And reading code to list all the return values of foo1() is time
consuming, so I ask for a utility can do the job automatically.
You won't find one. Just look at your first example, if foo2 or foo3
call other functions, you will very quickly get an exponential growth in
the number of possible returns for any function, or at best any valid
value of RTCODE.
Sounds like a pointless exercise to me.
--
Ian Collins. bi********@gmail.com wrote:
Hello everyone,
I'm updating some documents that describes so many C/C++
functions/method(about 2500).
But I'm not familiar with these codes. So I want to find such a utility
can generate returning value list from the codes.
Is it possible? Or is it hard to write one?
Thanks.
If I read you right (in this and your followup posts), all the relevant
functions return predetermined constants from a relatively small pool
of such (ruling out the division function someone else keeps
mentioning). If you are content with simply assuming that if a
function contains the line "return CONSTANT_BLAH" that it is somehow
possible for that function to indeed return CONSTANT_BLAH, then it
wouldn't be overwhelmingly difficult to just program your own simple
program to read in your .c files and parse them. When I say "it
wouldn't be overwhelmingly difficult" though, the emphasis is on
"overwhelmingly", this would probably be a week's worth of work if
you're new to file I/O and/or parsing text. (Well... this is assuming
you can assume the code is pretty well-behaved... if you wanted it to
be guaranteed to work no matter how scandalous the code in question,
then you'd practically have to include an entire preprocessor...)
On the other hand, if you want the program to be intelligent enough to
only count return lines which are actually reachable, then a general
solution would not be Turing computable since it would allow halting
oracles to be created...
S.P.
First suggestion:
Read the project's documentation to find the answers. If that is missing,
go polaxe the project's originator, until he provides the needed
information.
Second suggestion:
If he cannot be located for a good polaxing, then I suggest grepping through
the headers to find the enums and/or #defines that you are searching for and
building your case statements from those.
Third suggestion:
If the headers are missing and the documenation is missing, then it is
better to write a new solution from scratch (no, I'm not kidding). bi********@gmail.com (in 11**********************@m73g2000cwd.googlegroups. com) said:
|
| Morris Dovey wrote:
|| bi********@gmail.com (in
|| 11**********************@75g2000cwc.googlegroups.c om) said:
||
||| I'm updating some documents that describes so many C/C++
||| functions/method(about 2500).
||| But I'm not familiar with these codes. So I want to find such a
||| utility can generate returning value list from the codes.
||| Is it possible? Or is it hard to write one?
||
|| Consider just one possible function:
||
|| double binjobster_div(double a, double b)
|| { return a/b;
|| }
||
|| I think I'll let you answer your own question. :-)
| I'm sorry I forgot to mention that all the code here returns the
| same type. Let's say it's a predefined enumeration. So we won't get
| float or double.
Ok. My trivial example does provide a clue that a utility providing a
general solution isn't practical. If only enumerated values are
returned, then it should be sufficient to examine the sources to
determine which of the enumerated values are actually returned.
That certainly should be possible. Whether or not the utility you want
is hard to write depends on your own talents and skills...
--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA http://www.iedu.com/DeSoto
Snis Pilbor wrote:
If I read you right (in this and your followup posts), all the relevant
functions return predetermined constants from a relatively small pool
of such (ruling out the division function someone else keeps
mentioning). If you are content with simply assuming that if a
function contains the line "return CONSTANT_BLAH" that it is somehow
possible for that function to indeed return CONSTANT_BLAH, then it
wouldn't be overwhelmingly difficult to just program your own simple
program to read in your .c files and parse them. When I say "it
wouldn't be overwhelmingly difficult" though, the emphasis is on
"overwhelmingly", this would probably be a week's worth of work if
you're new to file I/O and/or parsing text. (Well... this is assuming
you can assume the code is pretty well-behaved... if you wanted it to
be guaranteed to work no matter how scandalous the code in question,
then you'd practically have to include an entire preprocessor...)
On the other hand, if you want the program to be intelligent enough to
only count return lines which are actually reachable, then a general
solution would not be Turing computable since it would allow halting
oracles to be created...
S.P.
Is there any similiar implementations or examples on the problem?
It need some parsing work. I have some experience on stdio and regexp
but don't on such software tools like YACC or bison.
<bi********@gmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
I'm sorry I'm a newbie on news group.
Functions may call another function like below:
RTCODE foo1(TYPE1 a1, TYPE2 a2)
{
if (cond1)
return foo2(...);
else if (cond2)
return foo3(...);
return ERROR_NONE;
}
RTCODE foo2(TYPE1 a1, TYPE2 a2)
{
....
return ERROR_OUT_OF_MEMORY;
}
And reading code to list all the return values of foo1() is time
consuming,
That's why code should be documented. The comments for foo2() and
foo3() should clearly state all possible return values; the comments
for foo1() should either enumerate all of those return values plus
ERROR_NONE, or they should say something like "returns ERROR_NONE or
the result of foo2() or foo3()" so that readers know to read through
those functions' comments as well.
In the absence of such documentation, you _must_ assume that foo1()
can return any possible value of type RTCODE (whatever that is). And,
in practice, it's generally a good idea to handle all possible values
even if the comments indicate they shouldn't happen, at least in debug
builds, so that you can handle errors in the comments.
so I ask for a utility can do the job automatically.
Since a utility can't read documentation, you won't get a satisfactory
answer. Fix the documentation and you won't need a utility anyways.
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
--
Posted via a free Usenet account from http://www.teranews.com
>I'm updating some documents that describes so many C/C++
>functions/method(about 2500). But I'm not familiar with these codes. So I want to find such a utility can generate returning value list from the codes. Is it possible? Or is it hard to write one?
If the function returns int, and it is written portably, then there are
no more than 65,536 different return values from that function.
(Although int can be larger than 16 bits and often is, portable C can't assume
that.)
If you've got a header file containing a bunch of definitions of error
codes, e.g.:
#define FAIL_LIPSTICK_AT_AIRPORT_SECURITY_GATE 7620
you could try counting the lines in the file.
I suspect determining all the possible return values from a function
is equivalent to the halting problem.
Gordon Burditt posted:
If the function returns int, and it is written portably, then there are
no more than 65,536 different return values from that function.
Correction: no more than 65 535 different return values.
Minimum range: -32 767 through 32 767
That's 65 535 unique values.
--
Frederick Gotham go***********@burditt.org (Gordon Burditt) wrote:
If you've got a header file containing a bunch of definitions of error
codes, e.g.:
#define FAIL_LIPSTICK_AT_AIRPORT_SECURITY_GATE 7620
YM
#define FAIL_WATER_BOTTLE_AT_AIRPORT_SECURITY_GATE 7620
#define FAIL_NECESSARY_MEDICINE_AT_AIRPORT_SECURITY_GATE 7621
Argh and cthulhudamn. I _was_ going to fly to London tomorrow and add
some money to the British economy. I'm having serious doubts now.
Richard
Gordon Burditt wrote:
<snip>
I suspect determining all the possible return values from a function
is equivalent to the halting problem.
Part of the problem of all possible return values is the halting
problem. Since one thing you have to determine is whether the function
will halt (i.e. return). If it never returns the number of possible
return values is 0.
--
Flash Gordon
Still sigless on this computer.
Frederick Gotham wrote:
Gordon Burditt posted:
>>If the function returns int, and it is written portably, then there are no more than 65,536 different return values from that function.
Correction: no more than 65 535 different return values.
Minimum range: -32 767 through 32 767
Correction: -32 768 through 32 767
For unsigned: 0 through 65 535
That's 65 535 unique values.
That's 65 536 values.
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Kevin Handy posted:
Frederick Gotham wrote:
>>>If the function returns int, and it is written portably, then there are no more than 65,536 different return values from that function.
>Correction: no more than 65 535 different return values.
Minimum range: -32 767 through 32 767
Correction: -32 768 through 32 767
Incorrect. The minimum range of an "int" is:
-32767 through 32767
It may so happen that on a system where int's are 32-Bit and are two's
complement, that the range is -32768 through 32767, but this cannot be
relied upon in portable code.
For unsigned: 0 through 65 535
>That's 65 535 unique values.
That's 65 536 values.
Yes, you're correct.
--
Frederick Gotham This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: B Moor |
last post by:
I have a database with 100,000's records, each with a unique
reference, eg
A123BNK456
I would like to generate a search facility whereby we can choose an
exact match or partial match, where the...
|
by: skishorev |
last post by:
Hi,
Here I am taking two functions. void f(int,int) and another one is
float f(int,int).
Is it possible to overload with return values.
Thx,
kishore
|
by: Alison Givens |
last post by:
....... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.
So, my question again:
I have the following problem.
(VB.NET 2003 with CR)
I have a...
|
by: lcaamano |
last post by:
We have a tracing decorator that automatically logs enter/exits to/from
functions and methods and it also figures out by itself the function
call arguments values and the class or module the...
|
by: Extremest |
last post by:
Here is the code I have so far. It connects to a db and grabs headers.
It then sorts them into groups and then puts all the complete ones
into another table. Problem I am having is that for some...
|
by: beach.dk |
last post by:
Hi,
I'm trying to implement a simple hash algorith called rs_hash in
javascript,
but I cannot get a correct result.
In c the code looks like this:
|
by: nomad |
last post by:
When I run choice == 2 I'm suppose to a an out.println back finding a product.
but I get Null for all the values.
Can someone help me with this.
class Computer_listing {
private String id;
...
|
by: Jeff |
last post by:
As I'm learning PHP, I'm making a fair number of mistakes in syntax.
In perl, you can turn on reading these errors from the browser by
adding this:
use CGI::Carp 'fatalsToBrowser';
Is there...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |