This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stupid question


Here is the code... It is changed a little bit, in order to reflect a compilable
program. Do not execute it!

#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>

gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
  
  int num_rows, num_cols;
  gsl_matrix * return_matrix;

  num_rows = m->size1;
  num_cols = m->size2;

  return_matrix = gsl_matrix_alloc ( num_rows , num_cols );

  return (gsl_matrix *) return_matrix;
}

int main () {
  (void*)matrix_return_upper((gsl_matrix*)NULL);
  return 0;
}

it does compile without problems under redhat7.2 and under gsl-1.0 with
gcc-3.0.2.
Maybe you come from c++ and are new to c - like me.
Be careful: Declarations have to be done before using the variables.

Yours, Achim


"Matthew J. Doller" schrieb:
> 
> can someone shed a tiny bit of light on why this seemingly simple
> routine is not compiling for me?
> 
> --- BEGIN CODE ---
> 
> #include "matrix-generic.h"
> #include <gsl/gsl_matrix.h>
> #include <gsl/gsl_vector.h>
> 
> gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
> 
>   int num_rows, num_cols, error;
> 
>   num_rows = m->size1;
>   num_cols = m->size2;
> 
>   gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
>   ...
>   ...
> 
>   return (gsl_matrix *) return_matrix;
> }
> 
> --- END CODE ---
> 
> compile command:
> gcc -o mytest matrix-generic.c -lgsl -lgslcblas -lm
> 
> compile errors:
> matrix-generic.c: In function `matrix_return_upper':
> matrix-generic.c:30: parse error before `*'
> 
> the * in question is from the line:
> gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
> for now, i have stripped out all the rest of the code after that line to
> simplify debugging.  please tell me that i'm over looking something
> simple.
> 
> thanks in advance
> matt
> 
> --
> Matthew J. Doller
> mdoller@wpi.edu
> http://www.wpi.edu/~mdoller


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]