473,386 Members | 1,706 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,386 software developers and data experts.

errno

On Wed, 05 May 2004, CBFalconer <cb********@yahoo.com> wrote:
Even if sscanf succeeds in inputting various fields, there are
probably range and other validity checks to be applied. The
interactive programmers work is never done :-)


in how I see it errno (or errno like) would have 32 states
0 /* No error */
1u, 2u, 4u, 8u, 16u, 32u, 64u, 128u, 256u, 512u, 1024u, 2048u
4096u, 8192u, 16384u, 32768u, 65536u, 131072u, 262144u,
524288u, 1048576u, 2097152u, 4194604u, 8388608u, 16777216u,
33554432u, 67108864u, 134217728u, 268435456u, 5356870912u,
1073741824u, 2147483648u. /* code error */

because seems to me that errors *sum themselves*
but are they enough ?
if(error_find_xxtype) errno |= error_find_xxtype;
Is there someone that reads my posts?

Nov 14 '05 #1
3 3822
On Wed, 05 May 2004 07:13:45 GMT, RoSsIaCrIiLoIA <n@esiste.ee> wrote:
On Wed, 05 May 2004, CBFalconer <cb********@yahoo.com> wrote:
Even if sscanf succeeds in inputting various fields, there are
probably range and other validity checks to be applied. The
interactive programmers work is never done :-)
in how I see it errno (or errno like) would have 32 states
0 /* No error */
1u, 2u, 4u, 8u, 16u, 32u, 64u, 128u, 256u, 512u, 1024u, 2048u
4096u, 8192u, 16384u, 32768u, 65536u, 131072u, 262144u,
524288u, 1048576u, 2097152u, 4194604u, 8388608u, 16777216u,
33554432u, 67108864u, 134217728u, 268435456u, 5356870912u,
1073741824u, 2147483648u. /* code error */


The error values of errno are of type int, not unsigned int. errno is
a macro or identifier with external linkage, that expands into a
modifiable lvalue. It has type int, and it is set equal to zero at
program startup. Positive numbers in the range of int are error
numbers, but I am not aware that the standard specifies any particular
number as one of the error numbers. The actual values are hidden by
the use of macros. The standard library uses errno to warn of an
error condition in some of the library functions such as EDOM for a
domain error in log().
because seems to me that errors *sum themselves*
but are they enough ?
if(error_find_xxtype) errno |= error_find_xxtype;
Is there someone that reads my posts?


I do not believe that you can or together errno errors. Perhaps you
have confused the values of math_errhandling that can be or'ed
together. The floating point exceptions macros can be or'ed together,
too.
--

Best wishes,

Bob
Nov 14 '05 #2
On Wed, 05 May 2004 07:13:45 GMT, RoSsIaCrIiLoIA <n@esiste.ee> wrote:
On Wed, 05 May 2004, CBFalconer <cb********@yahoo.com> wrote:
Even if sscanf succeeds in inputting various fields, there are
probably range and other validity checks to be applied. The
interactive programmers work is never done :-)


#include <stdio.h>
#include <stdint.h>

uint8_t errnov[16];

#define IN_FLAGS 0
#define OUT_FLAGS 1
#define ERR_FLAGS 2
#define MATH_FLAGS 3
#define FILE_FLAGS 4
#define DEVICE_FLAGS 5
#define SIGNALS_FLAGS 6
#define SYS_FLAGS 7
#define PROC_FLAGS 8
/* etc etc */

/* IN FLAGS */
#define IN_ERR 16u
#define IN_RANGE_ERR 8u
#define IN_EOF 4u
#define IN_UNGET 2u
#define IN_NONUM 1u

int main(void)
{int i;
printf("Inserisci un intero >"); fflush(stdout);
errnov[IN_FLAGS]=0;
scanf("%d", &i);
if(errnov[IN_FLAGS] & (IN_NONUM | IN_RANGE_ERR))
{
printf("errore\n");
}
else printf("i=%i\n", i);
return 0;
}

Nov 14 '05 #3
On Wed, 05 May 2004 14:39:45 GMT, RoSsIaCrIiLoIA <n@esiste.ee> wrote:
int main(void)
{int i;
printf("Inserisci un intero >"); fflush(stdout);
errnov[IN_FLAGS]=0;
scanf("%d", &i);
if(errnov[IN_FLAGS] & (IN_NONUM | IN_RANGE_ERR))
{
printf("errore\n");
}
else printf("i=%i\n", i);
return 0;
}


if "throw eccezione" == "errno[IN_FLAGS] |= eccezione"
this seems to me like the C++

int main(void)
{int i;

printf("Inserisci un intero >"); fflush(stdout);
try
{
scanf("%d", &i);
}
catch(IN_NONUM)
{
printf("errore\n");
return 0;
}
catch(IN_RANGE_ERR)
{
printf("errore\n");
return 0;
}
printf("i=%i\n", i);
return 0;
}

Nov 14 '05 #4

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

Similar topics

4
by: Richard Tobin | last post by:
In a library I am writing, I want to use an errno-like mechanism for error returns. The error would probably be represented as a struct rather than just an integer. I don't have any...
3
by: Mac | last post by:
Is it legal to declare errno after you've included errno.h? For example: #include<errno.h> .... int main (void) {
4
by: Paul Emmons | last post by:
If I am writing a function that sets errno according to a possible error condition, should it also set errno to 0 if it executes normally, or should it leave errno alone on success?
11
by: Vijay Kumar R Zanvar | last post by:
> In <pan.2004.04.22.04.06.05.969827@bar.net> "Mac" <foo@bar.net> writes: > > >Is it legal to declare errno after you've included errno.h? > > > >For example: > > > >#include<errno.h> > > >...
18
by: pete | last post by:
On my system, the following five expressions are true: (HUGE_VAL == HUGE_VAL / 2) (1 / HUGE_VAL == 0) (sqrt(HUGE_VAL) == HUGE_VAL) (sqrt(-1) == HUGE_VAL) (sqrt(-HUGE_VAL) == HUGE_VAL) and
5
by: Urs Beeli | last post by:
I have a question regarding errno. If I understand it correctly, including <errno.h> allows me to check "errno" for error values that some standard library functions may set. This brings up some...
3
by: eyalc1978 | last post by:
Hi Does someone knows what does errno 72 means I got this error when fwriting a structure and still the file is being created. I saw something on the net saying that this is caused when trying to...
13
by: Spiros Bousbouras | last post by:
Assume I'm writing a function which is going to set the value of errno if something went wrong but I also want to guarantee that errno will remain unchanged if the function completed its task...
22
by: viza | last post by:
Hi all, A quick one - since errno is a lvalue, can I do: fread( & errno, sizeof errno, 1, fp ) ? TIA viza
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.