在Xcode </iostream>中的.y文件中使用时,找不到<iostream>

时间:2012-03-30 17:00:50

标签: xcode yacc

我是Xcode的新手,我正在尝试迁移一个c ++应用程序,该应用程序在win32 cygwin中使用g ++ bison编译到Xcode。

在询问问题之前,我确实在网站上搜索了一些信息

我从一开始就遇到过问题,我把它缩小到以下几点。这是我的步骤:

  1. 在Xcode中创建一个新的控制台应用程序
  2. 这是一个没有自动引用计数的C ++应用程序
  3. 创建了一个main.cpp文件
  4. 评论主要程序
  5. 创建新文件simpleYACC.y
  6. 将以下内容复制到.y文件中:

    %{
        #include <iostream>
        //
        int yylex (void);    
        void yyerror (char const *);
    %}
    
    %token NUM
    
    %%
    exp:;
    %%
    
    int yylex (void)
    {
        return 0;
    }
    
    void
    yyerror (char const *s)
    {
    
    }
    
    int main (void)
    {
        return yyparse ();
    }
    
  7. 尝试构建

  8. 收到以下错误:
  9. CompileC /Users/brendanbosman/Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/SimpleYACC.build/Objects-normal/x86_64/Simple.tab.o/ Users / brendanbosman /Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/SimpleYACC.build/DerivedSources/Simple.tab.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler     cd“/源代码/ SimpleYACC”     setenv LANG en_US.US-ASCII     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -xc -arch x86_64 -fmessage-length = 0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field- initializers -Wmissing-prototypes -Wreturn-type -Wformat -Wno-missing-braces -Wharentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno- uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DDEBUG = 1 -isysroot / Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.platform / Developer / SDKs / MacOSX10.7.sdk -fasm-blocks -Wdeprecated-declarations -mmacosx-version-min = 10.7 -g -Wno-conversion -Wno- sign-conversion -iquote /Users/brendanbosman/Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/SimpleYACC.build/SimpleYACC-generated-files.hmap -I / Users / brendanbosman /图书馆/开发商/ Xcode中/导出Data / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Intermediates / SimpleYACC.build / Debug / SimpleYACC.build / SimpleYACC-own-target-headers.hmap -I / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build /中间体/ SimpleYACC.build / Debug / SimpleYACC.build / SimpleYACC-all-target-headers.hmap -iquote /Users/brendanbosman/Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/ SimpleYACC.build/SimpleYACC-project-headers.hmap -I / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Products / Debug / include -I / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Intermediates / SimpleYACC.build / Debug / SimpleYACC.build / DerivedSources / x86_64 -I / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Intermediates / SimpleYACC.build /调试/ SimpleYACC.build / d erivedSources -F / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Products / Debug -MMD -MT dependencies -MF / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build /Inmedmediates/SimpleYACC.build/Debug/SimpleYACC.build/Objects-normal/x86_64/Simple.tab.d-serialize- diagnostics / Users / brendanbosman / Library / Developer / Xcode / DerivedData / SimpleYACC-dglitxihrkprgndyxanispqjpbmc / Build / Intermediates / SimpleYACC.build/Debug/SimpleYACC.build/Objects-normal/x86_64/Simple.tab.dia -c /Users/brendanbosman/Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/ SimpleYACC.build/DerivedSources/Simple.tab.c -o /Users/brendanbosman/Library/Developer/Xcode/DerivedData/SimpleYACC-dglitxihrkprgndyxanispqjpbmc/Build/Intermediates/SimpleYACC.build/Debug/SimpleYACC.build/Objects-normal/x86_64/ Simple.tab.o

    /源代码/ SimpleYACC / SimpleYACC / Simple.y:6:14:致命错误:找不到'iostream'文件     #包括              ^ 生成1个错误。

    我对此错误有点了解,以及为什么我缺少&gt;

    我真的很感激任何帮助

    布伦丹

1 个答案:

答案 0 :(得分:1)

您在C源代码中包含了C ++头文件。 Bison生成一个C程序。如果要生成C ++解析器,请查看用其他语言编写的解析器部分下的Bison手册。