473,761 Members | 10,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

errno

On Wed, 05 May 2004, CBFalconer <cb********@yah oo.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_x xtype) errno |= error_find_xxty pe;
Is there someone that reads my posts?

Nov 14 '05 #1
3 3848
On Wed, 05 May 2004 07:13:45 GMT, RoSsIaCrIiLoIA <n@esiste.ee> wrote:
On Wed, 05 May 2004, CBFalconer <cb********@yah oo.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_xxty pe;
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_errhandlin g 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********@yah oo.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("Inseris ci 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("Inseris ci 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("Inseris ci 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
1557
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 multi-threaded programs, but others may who want to use my library. Most likely they'll be using a pthreads-compatible threads system. How can I best accommodate them? Presumably they will want the error object to be in per-thread storage, so to set and...
3
2439
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
9018
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
2531
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
3438
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
2367
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 questions: - As I understand it, most functions only set errno in an error case. I take this to mean, that on success, errno is not necessarily set to EOK and I would either need to set errno to EOK before calling the function in question to...
3
3392
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 access different file system
13
1938
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 succesfully. So at the beginning of my code I have something like int errsto = errno ; and just before every successful return I have errno = errsto ; Is this ok ?
22
2506
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
9531
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
10115
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
9957
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
9775
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...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5229
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...
1
3881
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
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.