igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Re: shared library error


From: sergiu netotea
Subject: Re: [igraph] Re: shared library error
Date: Thu, 27 Jan 2011 12:28:27 +0100

Dear Gabor,

I am doing that most of the time. I am also allocating the variable
properly and all that, but then whenever a simple check is not done
due to haste a C program will segfault. Since C is not throwing errors
the way an interpreted language does, it is good to have error checks.
Now I am not sure if it would be okay for igraph to test if the file
pointer is NULL or not when the programmer forgets, but throwing an
error would sure improve the life of the programmer. Checking errno
should have been the first thing to do for me, but I didn't and wasted
my time debugging. :(

On Thu, Jan 27, 2011 at 10:12 AM, Gábor Csárdi <address@hidden> wrote:
> On Thu, Jan 27, 2011 at 10:07 AM, sergiu netotea
> <address@hidden> wrote:
> [...]
>>    ifile=fopen(F1, "r");
>>    igraph_read_graph_edgelist(&g1,ifile,ng1,dir);
> [...]
>> Perhaps igraph should have a way of telling if the file was not opened
>> correctly although igraph cannot replace a programmer's bad practice.
>
> There is such a way, provided by the standard C library. You should
> check the return value of fopen():
>
> RETURN VALUES
>     Upon successful completion fopen(), fdopen(), and freopen() return a FILE
>     pointer.  Otherwise, NULL is returned and the global variable errno is
>     set to indicate the error.
>
> Gabor
>
>> Thanks,
>> Sergiu
>>
>
> --
> Gabor Csardi <address@hidden>     UNIL DGM
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]