Search Results

Search: Posts Made By: JohnGraham
Forum: Programming 03-06-2014
27,971
Posted By JohnGraham
You're thinking of configure scripts - they take...
You're thinking of configure scripts - they take a --prefix argument, makefiles don't.



Order of arguments with "make val=arg" doesn't matter either, and I don't know what you mean by the...
Forum: Programming 02-16-2014
937
Posted By JohnGraham
The problem is that: *i--; decrements...
The problem is that:

*i--;

decrements the pointer, not the pointed-to value. I.e. it's equivalent to:


*(i--);


What you really want is:


(*i)--;


(On my machine at least, your...
Forum: Programming 06-29-2013
4,006
Posted By JohnGraham
Kind of, but you seem to just be checking for a...
Kind of, but you seem to just be checking for a specific error. Generally for *NIX system calls:


The return value tells you whether there was an error or not, and
errno tells you the specific...
Forum: Programming 04-05-2013
5,016
Posted By JohnGraham
You're trying to make a template specialization,...
You're trying to make a template specialization, which means you need to use a concrete type instead of the generic T. So you could do e.g.:


template<> int* AddFun<int*>(int* i, int* j) {
...
Forum: Programming 10-18-2012
3,248
Posted By JohnGraham
When a number starts with a leading "0", it's...
When a number starts with a leading "0", it's interpreted as an octal number, which can only use digits 0-7 (inclusive). Fix this, recompile and see what the output is.

Also, do you know that...
Forum: Programming 10-16-2012
2,178
Posted By JohnGraham
They could - it's just a matter of style. Using...
They could - it's just a matter of style. Using '(1 << 3)' makes it explicitly clear that what you're dealing with a bit. They both mean the same thing to the compiler, it's just what they signal to...
Forum: Programming 10-13-2012
2,005
Posted By JohnGraham
See the man pages for opendir() and readdir().
See the man pages for opendir() and readdir().
Forum: Programming 10-13-2012
3,149
Posted By JohnGraham
These errors are nothing to do with #include...
These errors are nothing to do with #include files - your compiler is finding them just fine.

Your problem is that the compiler can't find where these functions are defined - it's seen a header...
Forum: Programming 10-07-2012
1,115
Posted By JohnGraham
When the compiler sees this, it sees " Hello...
When the compiler sees this, it sees " Hello "World"" as three things - a string " Hello ", the token World and an empty string, "". To get it to recognise the middle quotes as part of the string, as...
Forum: Programming 10-01-2012
1,979
Posted By JohnGraham
Could you post the code you're using?
Could you post the code you're using?
Forum: Programming 09-25-2012
1,247
Posted By JohnGraham
That's a variable declaration without a variable...
That's a variable declaration without a variable name; normally (only?) used in function signatures where you have to accept that type of argument, but don't actually want to use the variable. With...
Forum: Programming 12-29-2011
3,697
Posted By JohnGraham
Yes, this is a feature of both C and C++ - array...
Yes, this is a feature of both C and C++ - array names automatically decay into pointers where appropriate. When passing an array to a function, the array is never placed on the stack (how would the...
Forum: Programming 12-29-2011
7,543
Posted By JohnGraham
One mistake I notice straight-off is: ...
One mistake I notice straight-off is:


retval2=msgrcv(ad,&receive,1,1,0777);


The size parameter is in bytes, so it should be sizeof(receive) - your current code allows only a single byte to...
Forum: Programming 11-28-2011
18,024
Posted By JohnGraham
How are point1, point2 and randStart declared? ...
How are point1, point2 and randStart declared?

Also, as agma points out, it looks like you are confusing assignment and comparison:


// '=' assigns x the value 3
x = 3;

// '==' tests if x...
Forum: Programming 08-18-2011
1,479
Posted By JohnGraham
This is part of the C standard. Because the...
This is part of the C standard. Because the compiler can unambiguously determine that f in is a function pointer, it knows that "f()" can't mean anything else other than "a call to a function...
Forum: Programming 04-05-2011
1,880
Posted By JohnGraham
I believe it conforms to C99, but not C89 -...
I believe it conforms to C99, but not C89 - you'll get an error if you compile in 89 mode with the -pedantic flag.

I only see cons if you're going to port to a compiler that doesn't support this....
Forum: Programming 11-22-2010
6,427
Posted By JohnGraham
You'd define the type of the struct in the header...
You'd define the type of the struct in the header file, and declare (but not define) MEM_IO_PTRS in the header using extern:


/* in header file */

struct mem_ptrs
{
... /* members */
};...
Forum: Programming 11-11-2010
12,089
Posted By JohnGraham
That's an unusual question... why? There is...
That's an unusual question... why?

There is no signal to specifically flush all buffers, unless (i) a particular application includes a facility for specifically doing that or (ii) you don't mind...
Forum: Programming 11-10-2010
1,460
Posted By JohnGraham
You mean other than the C standard library...
You mean other than the C standard library (http://en.wikipedia.org/wiki/C_standard_library)? Well, on POSIX systems you have the POSIX library (http://en.wikipedia.org/wiki/C_POSIX_library) in...
Forum: Programming 10-25-2010
1,917
Posted By JohnGraham
No, file/socket descriptors are assigned on a...
No, file/socket descriptors are assigned on a per-process basis, so simply passing the descriptor to another process isn't possible. There are methods to do this, but they're more complicated than...
Forum: Programming 10-23-2010
3,846
Posted By JohnGraham
Are you sure you're entering "-c billy" and not...
Are you sure you're entering "-c billy" and not "-n billy"?

Also, one of your lines:


if(optarg=="billy")


will result in undefined behaviour. Try changing it to "if...
Forum: Programming 09-26-2010
2,381
Posted By JohnGraham
ssize_t is not a built-in type - I believe you'll...
ssize_t is not a built-in type - I believe you'll get it if you #include <stddef.h>.

EDIT: No, my bad - stddef.h is just for size_t - the signed variant is only POSIX, so it's in <sys/types.h>.
Forum: Programming 09-24-2010
4,194
Posted By JohnGraham
You probably don't have a static version of your...
You probably don't have a static version of your c library installed - confirm by running "whereis libc" (it should show a libc.so, but no libc.a) and search your package manager for "libc.a", "gcc...
Forum: Programming 09-23-2010
2,281
Posted By JohnGraham
The last line essentially makes the macro...
The last line essentially makes the macro evaluate to value, almost like it being "return value;" if SEARCH() were a function.
Forum: Programming 09-14-2010
14,722
Posted By JohnGraham
As a general rule (and this is only my opinion)...
As a general rule (and this is only my opinion) it's generally better to use the C standard library functions in stdio.h where you can (i.e. for file I/O) and then use the POSIX standard functions in...
Showing results 1 to 25 of 29

 
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy