X code。与升压"语义问题 - 未声明的标识符的va_start" [英] XCode with boost "Semantic Issue - undeclared identifier va_start"

查看:1399
本文介绍了X code。与升压"语义问题 - 未声明的标识符的va_start"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  C ++ locale.h文件
- >语义问题
- >使用未声明的标识符的'的va_start
- >语义问题
- >使用未声明的标识符的'va_end用来

使用升压,第一次下载了它使用的端口,并创造了X code进行命令行项目。
头文件搜索路径:/ usr / include目录/ **

有什么在code然而,就在主功能自带的默认凸出。

只是不知道该怎么办,没想到这种事情发生。

EDIT1:

第一次出现:

 的#ifndef _GLIBCXX_CSTDARG
#定义_GLIBCXX_CSTDARG 1GCC的#pragma system_header#包括LT&;比特/ C ++的config.h>
#包括LT&;&STDARG.H GT;//坚持ISO 14882第17.4.1.2第5条:1998
的#ifndef va_end用来
的#define va_end用来(AP)va_end用来(美联社)
#万一_GLIBCXX_BEGIN_NAMESPACE(STD)  使用:: va_list的;_GLIBCXX_END_NAMESPACE#万一

这是没有扩展名的文件的\\ usr \\包括\\ C ++ \\ 4.2.1,我只是意识到,这个文件没有任何与提升,这里发生的事情很讨厌。

EDIT2:固定后,include目录到/ opt /地方/有/ **新的错误出现了:

<$p$p><$c$c>/Applications/X$c$c.app/Contents/Developer/Toolchains/X$c$cDefault.xctoolchain/usr/lib/c++/v1/type_traits:214:46:
使用未声明的标识符nullptr_t'的;你的意思是nullptr?

有其他错误,凡是涉及到这些文件的文件夹SR / lib中/ C ++ / V1 /这是为什么?这些文件似乎是一些核心的功能,它们不能被打破了。

下面是错误的图片,也许瓯人看到的东西

EDIT3:改变从苹果LLVM到GCC LLVM编译器减少了错误只有一个:
vspintf不是'性病'中的一员,在C ++中locale.h文件。好了,现在我完全丧失。


解决方案

首先,你可能不会的#include ING正确的头文件。

例如,如果你不这样做的#include&LT; cstddef&GT; ,则不能使用的std :: nullptr_t ;试图这样做会给你:

 语义问题:未声明的标识符nullptr_t的用途。您的意思是'nullptr'?

通常,一个头拔恰好在其他各种头含蓄拉,这样的事情工作,即使他们不应该。的libstdc ++做这个有很多比的libc ++以上,而前者是LLVM-G ++(GCC LLVM),后者为铛(苹果LLVM),默认的库,这意味着大量的错误将似乎消失时切换到GCC LLVM(或只是坚持用苹果LLVM,并切换你的库),但你的code仍然是错误的。

另一种可能性是,你要编译C ++ 11在C ++ 03模式。例如,当你的#include&LT; cstddef&GT; 在C ++ 03模式时,它不应该定义 nullptr_t 。它可能这样做无论如何,它可能与LLVM-G ++和/或的libstdc ++这样做,但不能与铛和/或libc中++。但是你的code(或者,在这种情况下,你的项目)仍然是错误的,应该是固定的。

如果您能告诉我们的实际(简装)code产生这些错误,并告诉我们到底什么设置从您在X $ C $创建默认的命令行工具,C ++项目改变C(假设这是你创造了什么),应该可以更加具体。

要获得一个最小的程序与升压工作,假设你有X code,MacPorts的,并助推MacPorts的正确安装,所有你需要做的是这样的:


  • 创建一个新的命令行工具,C ++。

  • 单击该项目,然后在搜索路径,去头搜索路径,并编辑它以添加 /选择/本地/包括

  • 修改的main.cpp 来如下所示:

的main.cpp

 的#include&LT;&iostream的GT;
#包括LT&;升压/ UUID / uuid.hpp&GT;INT主(INT ARGC,为const char * argv的[])
{
    提高:: UUID的UUID :: = U1 {
        0×12,0x34,0x56,0x78,
        0×90,是0xAB,0XCD,0xef,
        0×12,0x34,0x56,0x78,
        0×90,是0xAB,0XCD,0xef};
    提高:: UUID的UUID :: = U2 {
        0×12,0x34,0x56,0x78,
        0×90,是0xAB,0XCD,0xef,
        0×12,0x34,0x56,0x78,
        0×90,是0xAB,0XCD,0xef};
    性病::法院LT&;&LT; (U1 U2 ==)LT;&LT; \\ n;
    返回0;
}

我挑的boost :: UUID,因为它是一个死简单库,但同样要编制升压的任何部分工作。

升压的某些部分还要求你在图书馆链接。对于这一点,你还需要添加的/ opt / local / lib目录来库搜索路径之前,你可以使用大部分的常用技术添加库的项目。

请注意,如果你是最新的,可以让这个更短,因为X code ++ 4.5,默认值将是苹果LLVM编译器4.1,GNU ++ 11的方言,或是libc ++与C ++ 11支持库。但我确信我的code是C ++ 03兼容的,因此它与默认工作在X $ C $的C几乎所有的版本(我用3.2测试),因为你从来没有告诉我们你使用的是什么版本。

C++locale.h
->Semantic Issue
-->Use of undeclared identifier 'va_start'
->Semantic Issue
-->Use of undeclared identifier 'va_end'

First time using boost, downloaded it using ports and created a command line project in XCode. Header Search Path: /usr/include/**

There is nothing in the code yet, just the main function that comes with the default proj.

Just don't know what to do, never expected this to happen.

EDIT1:

First occurrence:

#ifndef _GLIBCXX_CSTDARG
#define _GLIBCXX_CSTDARG 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <stdarg.h>

// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif

_GLIBCXX_BEGIN_NAMESPACE(std)

  using ::va_list;

_GLIBCXX_END_NAMESPACE

#endif

It's a file without extension in \usr\include\c++\4.2.1 and i just realized that this file has nothing to do with boost, there is something nasty happening here.

EDIT2: After fixing the include dir to /opt/local/include/** new errors appeared:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/type_traits:214:46:
Use of undeclared identifier 'nullptr_t'; did you mean 'nullptr'?

There are other errors, all related to these files in the folder sr/lib/c++/v1/ why is that? These file seems to be some core functionality, they can't be broke.

Here is a pic of the errors, maybe ou guys see something

EDIT3: Changing the compiler from Apple LLVM to GCC LLVM reduces the errors to only one: "vspintf is not a member of 'std'" in c++locale.h. Ok, now I'm completely lost.

解决方案

First, you're may not be #includeing the right headers.

For example, if you don't #include <cstddef>, you can't use std::nullptr_t; attempting to do so will give you:

Semantic issue: Use of undeclared identifier 'nullptr_t'. Did you mean 'nullptr'?

Often, pulling in one header happens to implicitly pull in various other headers, so things work even when they shouldn't. libstdc++ does this a lot more than libc++, and the former is the default library for llvm-g++ ("GCC LLVM"), the latter for clang ("Apple LLVM"), which means a lot of errors will seem to go away when you switch to "GCC LLVM" (or just stick with "Apple LLVM" and switch your library), but your code is still wrong.

Another possibility is that you're trying to compile C++11 in C++03 mode. For example, when you #include <cstddef> in C++03 mode, it shouldn't define nullptr_t. It might do so anyway—and it might do so with llvm-g++ and/or libstdc++, but not with clang and/or libc++. But your code (or, in this case, your project) is still wrong and should be fixed.

If you can show us the actual (stripped-down) code that generates these errors, and tell us exactly what settings you changed from the default "Command Line Tool, C++" project you created in Xcode (assuming that's what you created), it should be possible to be more specific.

To get a minimal program working with boost, assuming you've got Xcode, MacPorts, and MacPorts boost installed properly, all you have to do is this:

  • Create a new Command Line Tool, C++.
  • Click on the project, then under Search Paths, go to Header Search Paths, and edit it to add /opt/local/include.
  • Modify main.cpp to look like the following:

main.cpp

#include <iostream>
#include <boost/uuid/uuid.hpp>

int main(int argc, const char * argv[])
{
    boost::uuids::uuid u1 = {
        0x12, 0x34, 0x56, 0x78,
        0x90, 0xab, 0xcd, 0xef,
        0x12, 0x34, 0x56, 0x78,
        0x90, 0xab, 0xcd, 0xef };
    boost::uuids::uuid u2 = {
        0x12, 0x34, 0x56, 0x78,
        0x90, 0xab, 0xcd, 0xef,
        0x12, 0x34, 0x56, 0x78,
        0x90, 0xab, 0xcd, 0xef };
    std::cout << (u1 == u2) << "\n";
    return 0;
}

I picked boost::uuid because it's a dead-simple library, but the same should work for compiling any part of boost.

Some parts of boost also require you to link in a library. For that, you'll also need to add /opt/local/lib to Library Search Paths before you can use most of the usual techniques for adding libraries to a project.

Note that if you're up to date, you can make this even shorter, because with Xcode 4.5, the defaults will be Apple LLVM Compiler 4.1, GNU++11 dialect, and libc++ with C++11 support library. But I made sure my code was C++03-compatible so it works with the defaults in almost any version of Xcode (I tested with 3.2), since you never told us what version you were using.

这篇关于X code。与升压&QUOT;语义问题 - 未声明的标识符的va_start&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆