首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Visual Studio中存在无法解释的语法错误

Visual Studio中存在无法解释的语法错误
EN

Stack Overflow用户
提问于 2015-02-07 00:17:56
回答 1查看 340关注 0票数 1
代码语言:javascript
复制
#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

我收到一个编译错误:

代码语言:javascript
复制
Error 1 error C2143: syntax error : missing ';' before '*'

对于行:

代码语言:javascript
复制
cs_complex_t *x ;    /* numerical values, size nzmax */

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

EN

回答 1

Stack Overflow用户

发布于 2015-02-07 00:29:06

如果定义了宏NCOMPLEX,则您发布的代码将导致此错误。#ifndef NCOMPLEX中包含了cs_complex_t的两个定义。因此,如果定义了宏NCOMPLEX,则不会定义cs_complex_t,因此当编译器在cs_ci_sparse的定义中遇到它时,它将是一个无法解析的标识符。

我会说这是文件中的一个逻辑错误。如果cs_complex_t的定义依赖于NCOMPLEX的缺失,那么cs_complex_t的所有使用都应该依赖于它。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28370140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档