Here is relevant header of tree data structure:
#include <stdlib.h>
#ifndef KDTREE_H
#define KDTREE_H
#define DEFAULT_NUMBER_OF_DIMENSIONS 1
#define KD_TREE_HEAP_SIZE 100
#define MAX_DIMENSIONS 32
//References: https://www.geeksforgeeks.org/k-dimensional-tree/
//References: https://www.cs.cmu.edu/~ckingsf/bioinfo-lectures/kdtrees.pdf
//References:https://iq.opengenus.org/k-dimensional-tree/
/*
* Representation of a kd tree
*/
typedef struct tree_
{
struct tree *left;
struct tree *right;
float * info = (float *) calloc (MAX_DIMENSIONS, sizeof(float));
float distance_to_neighbor;
} tree;
The float * info = (float *) calloc (MAX_DIMENSIONS, sizeof(float));
throws compiler error:
kdtree.h:31:22: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
float * info = (float *) calloc (MAX_DIMENSIONS, sizeof(float));
Im able to do dynamic allocation outside of a struct but not inside of a struct? How can pre-allocate inside of a struct.