I'm trying to call GDALOpen
from a function to open a tiff raster and then use the dataset further in my main
or other functions.
This is the code I have so far:
int main( int argc, char* argv[] ){
GDALAllRegister();
GDALDataset *poRasterDataset;
openRaster(poRasterDataset, argv[1]);
...}
void openRaster(GDALDataset * poDataset, char* rasterName){
poDataset = (GDALDataset *) GDALOpen(rasterName, GA_ReadOnly);
...
}
My problem is if I do it this way my program crashes because it finds the poRasterDataset
to be empty in main
after calling openRaster
, but if I call GDALOpen
from main
I have no problem using the dataset. I'm not very experienced in C++ but I suppose it has to do with how I'm passing poDataset
in main
after calling openRaster
.