Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

C errors

derm0derm0 Member Posts: 4
Hi all,

Getting some more errors comin up when tryin 2 compile a c program in Ubuntu!

if((mkfifo(ENV_PICO_R_RD, FILE_MODE) < 0) && (errno != EEXIST)

I'm getting the following errors with the above line

'FILE_MODE' undeclared

syntax error before '<' token

Also with the following line which calls another function

frk(int in_fd, int out_fd)

I get the following error

syntax error before "int"

Any help or advice anyone has would be greatly appreciated.
Thanks again for all yer help

Derm

Comments

  • nugentnugent Member Posts: 87
    have you declared FILE_MODE ?

    mkfifo has the following prototype:

    int mkfifo(const char *pathname, mode_t mode);

    the second argument is mode_t which can be a bitwise OR'd list of any of the following ( declared in "sys/stat.h" )
    [code]
    S_IRUSR
    S_IREAD
    Read permission bit for the owner of the file.
    S_IWUSR
    S_IWRITE
    Write permission bit for the owner of the file.
    S_IXUSR
    S_IEXEC
    Execute (for ordinary files) or search (for directories) permission bit for the owner of the file.
    S_IRWXU
    This is equivalent to `(S_IRUSR | S_IWUSR | S_IXUSR)'.
    S_IRGRP
    Read permission bit for the group owner of the file.
    S_IWGRP
    Write permission bit for the group owner of the file.
    S_IXGRP
    Execute or search permission bit for the group owner of the file.
    S_IRWXG
    This is equivalent to `(S_IRGRP | S_IWGRP | S_IXGRP)'.
    S_IROTH
    Read permission bit for other users.
    S_IWOTH
    Write permission bit for other users.
    S_IXOTH
    Execute or search permission bit for other users.
    S_IRWXO
    This is equivalent to `(S_IROTH | S_IWOTH | S_IXOTH)'.
    S_ISUID
    This is the set-user-ID on execute bit.
    S_ISGID
    This is the set-group-ID on execute bit.
    S_ISVTX
    This is the sticky bit.
    [/code]
    So if you want read and write permissions
    [code]mkfifo(ENV_PICO_R_RD, S_IRUSR | S_IWUSR);[/code]

    [code]
    : if((mkfifo(ENV_PICO_R_RD, FILE_MODE) < 0) && (errno != EEXIST)
    ^^ ^-----------------------^ ^ ^ ^
    ||____________________________________| |_______________|
    |____________________________________________________________?????

    [/code]
    you're also missing a closing bracket at the end of this if statement

    : Also with the following line which calls another function
    :
    : frk(int in_fd, int out_fd)
    :
    : I get the following error
    :
    : syntax error before "int"

    this error is probably because of the above mention missing closing blacket

    ------
    nugent



Sign In or Register to comment.