error: pointer value used where a floating point value was expected in C code

error: pointer value used where a floating point value was expected in C code

我正在尝试编写一些代码,但有一个错误我不明白为什么我总是收到。 我想写入一个文件,并且我有一些函数可以 return 关于我构建的结构的不同信息。 这是我的代码:

IkResult productWriteToFile(AmountSet inventory, FILE *file){
    if (inventory == NULL) {
        return NULL_ARGUMENT;
    }

    fprintf(file, "Inventory status:\n");

    AS_FOREACH(Product, item, inventory){
        for(Product prod = (Product) asGetFirst(inventory); prod != NULL;
            prod = (Product) asGetNext(inventory)) {
            fprintf(file,"name: %s, id: %d, amount: %.3f, price: %.3f\n", getProductName(prod),
                    (int)getProductId(prod), prod -> amount, (double)((prod -> item) -> prodPrice));
        }
    }


    fclose(file);

    return SUCCESS;
}

这些是“辅助”功能:

unsigned int getProductId(Product prod){
    return (prod -> item) -> id;
}

char* getProductName(Product prod){
    return (prod -> item) -> name;
}

这些是我收到的错误:

In function ‘productWriteToFile’:
item.c:183:21: error: pointer value used where a floating point value was expected
                     (int)getProductId(prod), prod -> amount, (double)((prod -> item) -> prodPrice));

有人知道问题出在哪里吗?请帮忙 ><

更新---结构是:

typedef double (*GetProductPrice)(ProductData, const double amount);
typedef void *ProductData;

struct product_t{
    struct item_t item;
    double amount;
    Product* next;
};

struct item_t{
    char* name;
    int id;
    GetProductPrice prodPrice;
    AmountType type;
    ProductData ProductData;
    CopyData copy;
    FreeData free_data;
};

prodPrice成员的类型为GetProductPrice,其类型如下:

typedef double (*GetProductPrice)(ProductData, const double amount);

这个类型不是 double,而是指向 returns 和 double 的函数的指针。所以你需要调用函数。

prod->item->prodPrice(prod->item->ProductData, prod->amount)