Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Appleness

macrumors member
Original poster
Feb 26, 2009
34
1
I use to write command line apps for number crunching.

Recently I updated to SL and XCode 3.2, and I found that when I recovered and recompiled the projects I was developing, they seemed to build OK, but when I try to run them, they crash. They worked fine in Leopard and compiled with XCode 3.1.

I get messages like "Abort trap", and "Segmentation Fault".

I am not very keen on all the compiler options, so I do not know what to do.

Thanks for your help
 
If you can post the debugger where they crash that would help.

3.2 by default links against the 10.6 SDK which may do things a little differently (I just noticed this yesterday with a project I opened for the first time that crashed on SL but not on Leopard).
 
The line where it crash is that with the printf:

struct parametros *Lee_parametros( sorteo puntero, char *nombre_fichero )
{
FILE *fichero;
size_t tamano;
struct parametros *un_parametro;
int m;

tamano = sizeof(struct parametros);
un_parametro = (struct parametros *) malloc(tamano);
printf("[0][0]=%i\n",(*puntero)[0][0]);
.
.
.


where sorteo is declared in the header file as:

typedef int (*sorteo)[][10];
 
You can simplify your code a bit by doing this:

Code:
struct parametros *un_parametro = malloc(sizeof(struct parametros));

What are you actually attempting to do with that printf statement? That typedef does not make much sense to me. What are you trying to declare something that is basically function pointer syntax to be treated as an int?

Perhaps I am just misunderstanding your code here.
 
You can simplify your code a bit by doing this:

Code:
struct parametros *un_parametro = malloc(sizeof(struct parametros));

What are you actually attempting to do with that printf statement? That typedef does not make much sense to me. What are you trying to declare something that is basically function pointer syntax to be treated as an int?

Perhaps I am just misunderstanding your code here.

You are right with your simplifying statement.
"sorteo" is a pointer to a bidimensional array of int. I declared it with typedef to save typing in all the files where I use this kind of array.
The printf statement is useless (I just wrote it for debugging purposes).

I realize that the code is not perfect, but the question is why it crashes now, when it worked fine with Leopard and 3.1
 
Did you ever compile and run the code as 64-bit under Leopard? If not, then you might be incompatible with 64-bit. The problem could be with the default compilation architectures on Snow Leopard, which includes 64-bit. Turn off 64-bit on Snow Leopard and see what happens.
 
Did you ever compile and run the code as 64-bit under Leopard? If not, then you might be incompatible with 64-bit. The problem could be with the default compilation architectures on Snow Leopard, which includes 64-bit. Turn off 64-bit on Snow Leopard and see what happens.

Thankyou very much you all. That´s it. I turned off 64-bit, and now everything seems to work again.

And now, how can I make my code 64-bit compatible? I guess I will have to change a lot of things. Just give me a clue about where I should begin to look for.

Probably, my programs (heavy number crunching) would be much more efficient if compiled for 64-bit code. (?)

Thanks again (I love Mac Rumors)
 
Thankyou very much you all. That´s it. I turned off 64-bit, and now everything seems to work again.

And now, how can I make my code 64-bit compatible? I guess I will have to change a lot of things. Just give me a clue about where I should begin to look for.

Probably, my programs (heavy number crunching) would be much more efficient if compiled for 64-bit code. (?)

Thanks again (I love Mac Rumors)

Have a look around at the Apple developers website, they have quite a few articles about making your code work on 64 bit.

Always a good one is casting a pointer to an int and back (it's a stupid but common thing to do, works fine on 32 bit, crashes immediately on 64 bit), or thinking that int and long are the same size. Turn all the warnings on in XCode and fix all the problems; that is a good first step.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.