我想知道我的编译器是否支持C ++ 11,当使用const // create a lift event in LiftEvent
let liftEvent = LiftEvent(entity: liftEventEntity, insertIntoManagedObjectContext: managedObjectContext)
let dateStr = "05-27-2016"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
let date: NSDate = dateFormatter.dateFromString(dateStr)!
liftEvent.date = date
liftEvent.liftEventUid = 1
liftEvent.liftUid = 1
liftEvent.formulaUid = 1
liftEvent.maxAmount = 250
print("Added lift ID: \(liftEvent.liftEventUid) lift ID: \(liftEvent.liftUid) weight: \(liftEvent.maxAmount) formula: \(liftEvent.formulaUid) ")
saveContext()
}
func saveContext () {
if managedObjectContext.hasChanges {
do {
try managedObjectContext.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
NSLog("Unresolved error \(nserror), \(nserror.userInfo)")
abort()
}
}
}
来了解C ++版本时,我发现打印__cplusplus
。
此版本号是否表示编译器支持C ++ 11?
注意:我正在使用199711
。
答案 0 :(得分:2)
MSVC存在问题(即缺乏C ++ 11 / C ++ 14支持):
所以不,就MSVC而言,这个值并不意味着什么具体。一些C ++ 11功能可以完美运行,有些功能会失败。因此,这个C ++ 99-ish值在其中有一定的意义;您最好的选择是检查特定功能(请参阅下面的cxx11tests
链接)。
更多信息:
https://msdn.microsoft.com/pl-pl/library/hh567368.aspx
https://stackoverflow.com/a/27459246/719662
How to Detect if I'm Compiling Code With Visual Studio 2008?