Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 叮当声错误:函数定义已声明';typedef';_Ios_Objective C_Clang - Fatal编程技术网

Ios 叮当声错误:函数定义已声明';typedef';

Ios 叮当声错误:函数定义已声明';typedef';,ios,objective-c,clang,Ios,Objective C,Clang,我正在使用clang编译我的代码,但我得到一个错误,代码和错误如下: /Users/fenglihai/llvm/llvm_build/Debug/bin/ClangConfuse /Users/fenglihai/Desktop/Test/Test/ITXAppdelegate.m /Users/fenglihai/Desktop/Test/Test/main.m /Users/fenglihai/Desktop/Test/Test/MainViewController.m /Users/fe

我正在使用clang编译我的代码,但我得到一个错误,代码和错误如下:

/Users/fenglihai/llvm/llvm_build/Debug/bin/ClangConfuse /Users/fenglihai/Desktop/Test/Test/ITXAppdelegate.m /Users/fenglihai/Desktop/Test/Test/main.m /Users/fenglihai/Desktop/Test/Test/MainViewController.m /Users/fenglihai/Desktop/Test/Test/VTEnumType.h /Users/fenglihai/Desktop/Test/Test/ITXAppdelegate.h /Users/fenglihai/Desktop/Test/Test/MainViewController.h -- -w -std=gnu11 -fobjc-abi-version=2 -Wnullability-completeness -Wno-arc-repeated-use-of-weak -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -isystem /Users/fenglihai/llvm/llvm_build/Debug/lib/clang/9.0.0/include -Wnull-dereference -fobjc-weak -ObjC -mios-simulator-version-min=8.0 -ObjC -lSDWebImage -lSVProgressHUD -lYYCache -lYYCategories -lc++ -ljcore-ios-1.2.6 -ljpush-ios-3.1.2 -lpop -lresolv -lsqlite3 -lz -framework Accelerate -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreImage -framework CoreTelephony -framework CoreText -framework Foundation -framework ImageIO -framework QuartzCore -framework Security -framework SystemConfiguration -framework UIKit -weak_framework UserNotifications -I/Users/fenglihai/Desktop/Test/Test -I/Users/fenglihai/Desktop/Test/Test -I/Users/fenglihai/Desktop/Test/Test -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/JPush -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/SDWebImage -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/SVProgressHUD -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/YYCache -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/YYCategories -I/Users/fenglihai/Desktop/Test/Pods/Headers/Public/pop 
我得到一个错误:

/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:13:44: error: function definition declared 'typedef'
typedef NS_ENUM(NSUInteger, VTLayoutStyle) {
                                           ^
/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:15:5: error: use of undeclared identifier 'VTLayoutStyleDefault'
    VTLayoutStyleDefault,
    ^
/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:17:5: error: use of undeclared identifier 'VTLayoutStyleDivide'; did you mean 'VTLayoutStyle'?
    VTLayoutStyleDivide,
    ^~~~~~~~~~~~~~~~~~~
    VTLayoutStyle
/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:13:29: note: 'VTLayoutStyle' declared here
typedef NS_ENUM(NSUInteger, VTLayoutStyle) {
                            ^
/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:19:5: error: use of undeclared identifier 'VTLayoutStyleCenter'; did you mean 'VTLayoutStyle'?
    VTLayoutStyleCenter,
    ^~~~~~~~~~~~~~~~~~~
    VTLayoutStyle
/Users/fenglihai/Desktop/Test/Test/VTEnumType.h:13:29: note: 'VTLayoutStyle' declared here
typedef NS_ENUM(NSUInteger, VTLayoutStyle) {
                            ^
4 errors generated.
Error while processing /Users/fenglihai/Desktop/Test/Test/VTEnumType.h.

VTEnumType.h

#ifndef VTEnumType_h
#define VTEnumType_h

/** 导航栏布局样式 */
typedef NS_ENUM(NSUInteger, VTLayoutStyle) {
    /** 默认样式,item自适应文本宽度,间距由itemSpacing决定 */
    VTLayoutStyleDefault,
    /** items等分导航条宽度,常用于item数较少时 */
    VTLayoutStyleDivide,
    /** 导航栏居中布局,间距由itemSpacing决定 */
    VTLayoutStyleCenter,
};



#endif /* VTEnumType_h */


ITXAppdelegate.m

#import "ITXAppdelegate.h"
#import "VTEnumType.h"

@interface ITXAppdelegate ()
@property (nonatomic, assign) VTLayoutStyle height;
@end

@implementation ITXAppdelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.height =VTLayoutStyleDefault ;
    return YES;
}

@end


如果您是通过直接命令行将项目构建到clang,那么我认为发生的事情是您将头文件(.h)指定给clang作为源文件,而不是源文件

这是如果
NS_ENUM
宏不可用时会出现的错误——编译器只是对您试图在那里执行的操作感到困惑。宏通常是通过标准基金会提供的,COCOA包括头文件,但是如果编译器试图将您的头文件作为自己的源文件,那么该头不包括基础,因此EnUM的东西在那时没有定义。
更重要的是,您应该只要求clang编译源单元(.m)。编译器将在运行时看到对头的引用,并根据需要通过预处理器加载它们。如果在执行此操作时找不到所需的标题,它将通知您。

嗨,Lh,欢迎登机!很难看到这里到底发生了什么——理想情况下,您可以缩小导致错误的代码片段,并发布有问题的代码。在您的情况下,错误看起来是
error:function definition声明为'typedef'typedef NS_ENUM(NSUInteger,VTLayoutStyle)
请查看此页面,它可能有助于您的ENUM定义:确定~我已添加了代码