Makefile Linux

J

James Kuyper

On 06/15/2012 03:59 PM, Barry wrote:
....
what does unixbf.c do , it is important for the program?

It provides alternative, implementations of C standard library functions
such as fopen(), fread(), etc. That kind of thing is, at best, a
dangerous thing to do. However, it doesn't even compile. It uses FSSpec
as if it were a valid type name, despite the complete absence of any
definition for that identifier anywhere in the code.
 
P

Phil Carmody

Jorgen Grahn said:
This is kind of offtopic, but ... it has some features I like
(dependency generation) and some I don't like (a split of header files
and .c files into separate directories; too many variables and
wildcards hiding what's really happening).

And I don't understand what's "visual" or "stupid" about it.

Elsewhere on that site (under ~jhl, obviously):

char *strncpy(char *dst, const char *src, size_t n)
{
char *p = dst;

while (n && (*dst++ = *src++)) n--;
if (!n) *dst = '\0';
return p;
}

Try that with:

char dst[2];
const char src[] = "stupid";
size_t n = sizeof(dst); // n=2
strncpy(dst, src, n); // copies 's', copies 't', breaks loop, writes a \0 - BANG!

Let he who is without stupid cast the first stone.

Phil, who occasionally, fortunately albeit briefly, harnesses the power of stupid.
--
I'd argue that there is much evidence for the existence of a God.
Pics or it didn't happen.
-- Tom (/. uid 822)
 
8

88888 Dihedral

Phil Carmodyæ–¼ 2012å¹´9月5日星期三UTC+8上åˆ5時40分24秒寫é“:
Elsewhere on that site (under ~jhl, obviously):



char *strncpy(char *dst, const char *src, size_t n)

{

char *p = dst;



while (n && (*dst++ = *src++)) n--;

if (!n) *dst = '\0';

return p;

}
Are dst and srn non-overlapping in the memeory space? This is a good example in C to teach pointers.

But for a 32-bit cpu a well-tuned memcpy
in assembly is preferred.

Anyway there are 8051, 8052, and 8086 level MCUs on
the markete for applications that focus on cheap parts.


Try that with:



char dst[2];

const char src[] = "stupid";

size_t n = sizeof(dst); // n=2

strncpy(dst, src, n); // copies 's', copies 't', breaks loop, writes a \0- BANG!



Let he who is without stupid cast the first stone.



Phil, who occasionally, fortunately albeit briefly, harnesses the power of stupid.

--
I'd argue that there is much evidence for the existence of a God.

Pics or it didn't happen.

-- Tom (/. uid 822)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,078
Messages
2,570,570
Members
47,204
Latest member
MalorieSte

Latest Threads

Top