PDA

View Full Version : [C] How do you read this? What does it mean?

cguy
March 6th, 2011, 03:52 PM
this:

extern int *_ _errno_location(void);
#define errno (*_ _errno_location())

(Edit) and this:

#define SIG_ERR (void (*)())-1

Thanks!

Aikar
March 6th, 2011, 05:12 PM
It's basically aliases.

say

return SIG_ERR;

is same as

return ((void (*)())-1;

But I think they are getting carried away with it.

cguy
March 6th, 2011, 05:23 PM
Aliases, yes.
But the syntax eludes me.

It's part of POSIX.

cguy
March 6th, 2011, 09:50 PM
I also have some questions from an online test I took:

Which of the following statements accurately describes the intended effect of the declaration: int (* a)[10]; ?
Choose only one of the following
An array of ten integers
A pointer to an array of ten integers
An array of ten pointers to integers
An array of ten pointers to functions

Which of the following is a correct way to write the value 0xAA55 to physical memory address 0x67A9?
Choose only one of the following
uint16_t * p = (uint16_t *) 0x67A9; p = 0xAA55;
uint16_t * p = (uint16_t *) 0xAA55; p = 0x67A9;
* (uint16_t * const) (0x67A9) = 0xAA55;
* (uint16_t * const) (0xAA55) = 0x67A9;

Thanks!

trent.josephsen
March 6th, 2011, 10:43 PM
What is this, free homework help?

http://cdecl.org/

cguy
March 6th, 2011, 11:28 PM
No. It's free ''I had an online job interview and will have another one tomorrow, this time face to face, so I'm trying to clarify some things''-help.

Thanks for the link, but I dislike the attitude. When you don't like a thread don't contribute.

Arndt
March 7th, 2011, 12:15 AM
No. It's free ''I had an online job interview and will have another one tomorrow, this time face to face, so I'm trying to clarify some things''-help.

Thanks for the link, but I dislike the attitude. When you don't like a thread don't contribute.

Maybe, but you could clarify things yourself, too, for example say what it is with these questions that you have problems with, not just ask what the answer is.

gmargo
March 7th, 2011, 03:12 AM
You can also install the cdecl package and get the same (or similar?) functionality as http://cdecl.org/ in a command line tool.

http://packages.ubuntu.com/maverick/cdecl

\$ cdecl explain "int (* a)[10];"
declare a as pointer to array 10 of int

Milliways
March 7th, 2011, 08:22 AM
No. It's free ''I had an online job interview and will have another one tomorrow, this time face to face, so I'm trying to clarify some things''-help.

Thanks for the link, but I dislike the attitude. When you don't like a thread don't contribute.

cdecl.org will explain c constructs.
It is also available as an executable cdecl

extern int *_ _errno_location(void); is meaningless, but

int * _errno_location(void); means
declare _errno_location as function (void) returning pointer to int