c++ - Visual Studio 中无法解释的语法错误

标签 c++ visual-studio

#ifndef _CXS_H
#define _CXS_H
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#ifdef MATLAB_MEX_FILE
#include "mex.h"
#endif


#ifdef __cplusplus
#ifndef NCOMPLEX
#include <complex>
typedef std::complex<double> cs_complex_t ;
#endif
extern "C" {
#else
#ifndef NCOMPLEX
#include <complex.h>
#define cs_complex_t double _Complex
#endif
#endif

#define CS_VER 2                    /* CXSparse Version */
#define CS_SUBVER 3
#define CS_SUBSUB 0
#define CS_DATE "Jun 1, 2012"       /* CXSparse release date */
#define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006-2012"
#define CXSPARSE

#include "SuiteSparse_config.h"
#define cs_long_t       SuiteSparse_long
#define cs_long_t_id    SuiteSparse_long_id
#define cs_long_t_max   SuiteSparse_long_max

         ........................

typedef struct cs_ci_sparse  /* matrix in compressed-column or triplet form */
{
    int nzmax ;     /* maximum number of entries */
    int m ;         /* number of rows */
    int n ;         /* number of columns */
    int *p ;        /* column pointers (size n+1) or col indices (size nzmax) */
    int *i ;        /* row indices, size nzmax */
    cs_complex_t *x ;    /* numerical values, size nzmax */
    int nz ;        /* # of entries in triplet matrix, -1 for compressed-col */
} cs_ci ;

   ....................
#ifdef __cplusplus
}
#endif
#endif

我遇到编译错误:

Error 1 error C2143: syntax error : missing ';' before '*'

对于行:

cs_complex_t *x ;    /* numerical values, size nzmax */

由于文件的大小,一些不相关的部分丢失了。给定这个代码段,有什么可以解释这个错误的吗?这个项目是一个类似 Spice 的模拟器。

最佳答案

如果定义了宏 NCOMPLEX,您发布的代码将导致此错误。 cs_complex_t 的两个定义都包含在 #ifndef NCOMPLEX 中。因此,如果定义了宏 NCOMPLEX cs_complex_t被定义,因此当编译器在 cs_ci_sparse 的定义中遇到它。

我会说这是文件中的逻辑错误。如果 cs_complex_t 的定义取决于 NCOMPLEX 的缺失,则 cs_complex_t 的所有使用也应该取决于它。

关于c++ - Visual Studio 中无法解释的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28370140/

相关文章:

iphone - 关于xcode中浮点值的问题

c# - SQLite 和 .NET 用户控件

android - 使用 visual studio 2015 安装 xamarin

sql-server - 存储过程 ENCRYPTION 选项取决于构建模式

javascript - 将最终的 Typsecript 导出包装在模块中?

visual-studio - 更新到 Visual Studio 2017 版本 15.4

c++ - 在 ubuntu 中使用 tesseract

c++ - 如何在 C++ 中使用 if-then 语句正确计算用户输入

c++ - Eigen Vector4d 作为函数参数?

c++ - declval<T>() 是否与 (*(T*)nullptr) 相同?