|
From: | Charles Novaes de Santana |
Subject: | Re: [igraph] Problems reading the number of vertices of a pajek-file using C-Igraph in a 64-bits machine |
Date: | Mon, 10 Dec 2012 12:30:25 +0100 |
Thank you guys, for your quick answer! Tamas: I understand what you say. I tried exactly the same casting you suggested me, but unfortunately nothing changed. In attach I am sending the source file (as I said, it is the same "foreign.c" that is in the igraph manual). Gábor: I am sending also the output of the ldd foreign, the commands I use to compile it, the way I run it (./foreign), and the output I got when I run it. I hope it helps us to understand what it is happening. I was wondering if it may be an error because I am compiling the igraph in my home, and so because of it I am doing something wrong when I am linking the libraries during the compilation. Thank you for your attention, Best, Charles On Mon, Dec 10, 2012 at 10:45 AM, Tamás Nepusz <address@hidden> wrote: > Dear Charles, > >> number of vertices of a network from in simple pajek file. The program >> compiles correctly, it reads the edges of the network correctly, but >> it reads the number of vertices like a strange number, like -10585152. > I'm 99% sure that this is a printing/formatting issue, i.e. the number in the > variable is fine but you print it with the wrong format string. The reason > why it happens on a 64-bit machine only is because the variable type that > printf expects for that particular format string that you are using happens > to be of the same length as your actual variable on a 32-bit machine but not > on a 64-bit machine. > > For the record, igraph_vcount returns the vertex count in an > igraph_integer_t. _Internally_, igraph_integer_t used to be a double before > igraph 0.6, but that confused the hell out of people (including me) so we > switched to igraph_integer_t being a long int. That being said, the safest > way to print an igraph_integer_t is by casting it explicitly to a long int to > make sure that the code works with every igraph version: > > igraph_integer_t whatever; > [...] > printf("whatever = %ld\n", (long int)whatever); > > Best, > Tamas > > > _______________________________________________ > igraph-help mailing list > address@hidden > https://lists.nongnu.org/mailman/listinfo/igraph-help -- Um axé! :) -- Charles Novaes de Santana http://www.imedea.uib-csic.es/~charles PhD student - Global Change Laboratorio Internacional de Cambio Global Department of Global Change Research Instituto Mediterráneo de Estudios Avanzados(CSIC/UIB) Calle Miquel Marques 21, 07190 Esporles - Islas Baleares - España Office phone - +34 971 610 896 Cell phone - +34 660 207 940
run_foreign.sh
Description: Bourne shell script
output_foreign.dat
Description: Binary data
ldd_foreign.dat
Description: Binary data
foreign.c
Description: Text Data
compile_foreign.sh
Description: Bourne shell script
LINKS.NET
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |