远期申报的替代方案

时间:2015-07-29 09:21:45

标签: c++

我注意到[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.808 s [INFO] Finished at: 2015-07-29T14:08:21+05:00 [INFO] Final Memory: 7M/18M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.4:endpoints_get_discovery_doc (default) on project helloworld: Execution default of goal com.google.appengine:appengine-maven-plugin:1.9.4:endpoints_get_discovery_doc failed: A required class was missing while executing com.google.appengine:appengine-maven-plugin:1.9.4:endpoints_get_discovery_doc: com/google/api/server/spi/config/Api [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>com.google.appengine:appengine-maven-plugin:1.9.4 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/C:/Users/error/.m2/repository/com/google/appengine/appengine-maven-plugin/1.9.4/appengine-maven-plugin-1.9.4.jar [ERROR] urls[1] = file:/C:/Users/error/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar [ERROR] urls[2] = file:/C:/Users/error/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar [ERROR] urls[3] = file:/C:/Users/error/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar [ERROR] urls[4] = file:/C:/Users/error/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar [ERROR] urls[5] = file:/C:/Users/error/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.0.0.M2a/org.eclipse.sisu.inject-0.0.0.M2a.jar [ERROR] urls[6] = file:/C:/Users/error/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar [ERROR] urls[7] = file:/C:/Users/error/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.16/plexus-interpolation-1.16.jar [ERROR] urls[8] = file:/C:/Users/error/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.10/plexus-utils-3.0.10.jar [ERROR] urls[9] = file:/C:/Users/error/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar [ERROR] urls[10] = file:/C:/Users/error/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar [ERROR] urls[11] = file:/C:/Users/error/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[12] = file:/C:/Users/error/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar [ERROR] urls[13] = file:/C:/Users/error/.m2/repository/com/google/guava/guava/14.0.1/guava-14.0.1.jar [ERROR] urls[14] = file:/C:/Users/error/.m2/repository/com/google/appengine/appengine-tools-sdk/1.9.4/appengine-tools-sdk-1.9.4.jar [ERROR] urls[15] = file:/C:/Users/error/.m2/repository/com/google/appengine/appengine-local-endpoints/1.9.4/appengine-local-endpoints-1.9.4.jar [ERROR] urls[16] = file:/C:/Users/error/.m2/repository/com/google/appengine/appengine-endpoints/1.9.4/appengine-endpoints-1.9.4.jar [ERROR] urls[17] = file:/C:/Users/error/.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.4/appengine-api-1.0-sdk-1.9.4.jar [ERROR] urls[18] = file:/C:/Users/error/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar [ERROR] urls[19] = file:/C:/Users/error/.m2/repository/eu/infomas/annotation-detector/3.0.1/annotation-detector-3.0.1.jar [ERROR] urls[20] = file:/C:/Users/error/.m2/repository/org/slf4j/slf4j-nop/1.7.5/slf4j-nop-1.7.5.jar [ERROR] urls[21] = file:/C:/Users/error/.m2/repository/org/apache/maven/shared/maven-invoker/2.0.11/maven-invoker-2.0.11.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: com.google.api.server.spi.config.Api [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException class关键字添加到原本需要向前声明的类型,就好像该类型是向前声明的那样:

struct

我没有意识到这一点。我想知道它是标准的C ++还是扩展,以及参数之前的// struct Test; forward declaration commented void* foo(struct Test* t) // C style function parameter - This works ! { return t; } 关键字是否作为前向声明或其他机制起作用。

此外,在这样的用法之后,“next”函数可以使用该类型而不需要添加任何关键字:

struct

Demo

1 个答案:

答案 0 :(得分:6)

这是合法的,但可能不是一个好主意。

来自 [basic.scope.pdecl] / 6:

  

[...] - 用于形式
详细类型说明符    class-key 标识符
  如果在 decl-specifier-seq 参数声明子句中使用 elaborated-type-specifier   在命名空间作用域中定义的函数, 标识符在命名空间中声明为类名   包含声明 [...]

例如:

namespace mine {
    struct T* foo(struct S *);
//  ^^^^^^^^^---------------- decl-specifier-seq
//                ^^^^^^^^^^--- parameter-declaration-clause
}

这会将TS作为类名称,将foo作为函数名称引入namespace mine

请注意,C中的行为不同;结构名称仅在函数范围内有效。

  

6.2.1标识符范围

     

4 - [...]如果是声明符或类型说明符   声明标识符出现在[...]参数声明列表中   一个函数定义,标识符有块范围,它终止于   相关块。如果出现声明标识符的声明符或类型说明符   在函数原型的参数声明列表中(不是函数的一部分)   定义),标识符有函数原型范围,它终止于   函数声明者。

gcc在C代码中为此用法提供了适当的警告:

a.c:3:18: warning: ‘struct Test’ declared inside parameter list
 void* foo(struct Test* t)
                  ^
a.c:3:18: warning: its scope is only this definition or declaration, which is probably not what you want