我有下面的课:
class Cdata12Mnt
{
public:
char IOBname[ID1_IOB_PIOTSUP-ID1_IOB_TOP][BOADNAM_MAX + 4];
char ExIOBname[ID1_MAX_INF-ID1_EXIOB_U1TOP][BOADNAM_MAX + 4];
char cflpath[256];
char basetext[256];
UINT database[ID1_MAX_INF];
int State;
public:
char SelectPath[256];
public:
int GetIOBName(int slt,char *Name);
Cdata12Mnt(char *SelectPath);
virtual ~Cdata12Mnt();
int GetValue(int id);
int GetState() { return State; }
};
Run Code Online (Sandbox Code Playgroud)
我的功能如下:
Cdata12Mnt::Cdata12Mnt(char *SelectPath)
{
SCTReg reg;
char buf[256], *cpnt, *npnt, *bpnt1, *bpnt2;
char *startcode[] = {"CNTL_CODE ","SEGMENT "};
char *stopcode = {"END_CNTL_CODE "};
FILE *fp;
int ii, infl;
State = 0;
for (ii = 0; ii < …Run Code Online (Sandbox Code Playgroud) 假设以下代码:
#include <iostream>
using namespace std;
namespace X
{
class A{};
void f(A a){}
void g(int a){}
}
int main()
{
X::A a;
f(a);
g(5);
}
Run Code Online (Sandbox Code Playgroud)
编译代码时,会发生以下编译错误:
main.cpp:在函数'int main()'中:
main.cpp:error:'g'未在此范围内声明
所以函数f编译得很完美,但事实g并非如此.怎么样?它们都属于同一名称空间.编译器是否从类型的参数中推断出该函数f属于X命名空间X::A?在这种情况下编译器如何表现?
请不要与标题混淆,因为它已被某人询问,但不同的背景
Visual C++编译器(VS2008)中的以下代码未编译,而是抛出此异常:
std::ifstream input (fileName);
while (input) {
string s;
input >> s;
std::cout << s << std::endl;
};
Run Code Online (Sandbox Code Playgroud)
但是这个代码在cygwin g ++中编译得很好.有什么想法吗?
'System.Data.SqlClient.SqlConnection'没有名为'Query'的适用方法,但似乎有一个名称的扩展方法.无法动态分派扩展方法.考虑转换动态参数或调用扩展方法而不使用扩展方法语法.
现在,我知道如何解决这个问题,但我正在努力更好地理解错误本身.我正在上课,以利用Dapper.最后,我将提供一些更多自定义功能,以使我们的数据访问类型更加简化.特别是在追踪和东西建设.但是,现在它就像这样简单:
public class Connection : IDisposable
{
private SqlConnection _connection;
public Connection()
{
var connectionString = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
_connection = new SqlConnection(connectionString);
_connection.Open();
}
public void Dispose()
{
_connection.Close();
_connection.Dispose();
}
public IEnumerable<dynamic> Query(string sql, dynamic param = null, IDbTransaction transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
{
// this one works fine, without compile error, so I understand how to
// workaround the error
return Dapper.SqlMapper.Query(_connection, sql, param, transaction, buffered, …Run Code Online (Sandbox Code Playgroud) 我有一个(看似)简单的maven问题我无法解决.在我的POM中,我已经指定了对openrdf-sesame的依赖,如下所示:
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>2.7.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
从eclipse运行项目效果很好,我甚至可以导出一个可运行的jar文件.不幸的是,我无法通过cmd-line maven正常工作.为了建立一个罐子,我已经将以下内容添加到我的pom中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>foo.bar.Cli</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
编译失败,出现以下错误:
.../PLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../PLDReducer.java:[27,33] package org.openrdf.sail.nativerdf does not exist
.../LowPLDReducer.java:[25,29] package org.openrdf.rio.rdfxml does not exist
.../Cli.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../SchemaBuilder.java:[30,33] package org.openrdf.sail.nativerdf does not exist
.../RepoQuerier.java:[23,33] package org.openrdf.sail.nativerdf does not exist
.../PLDReducer.java:[78,44] cannot find symbol
Run Code Online (Sandbox Code Playgroud)
奇怪的是,只要我将编译插件添加到pom并更新项目设置,eclipse似乎也不再编译了.我检查了我的存储库,所有芝麻文件都在那里.
mvn --version给出了这个输出:
Apache Maven …Run Code Online (Sandbox Code Playgroud) 其他答案建议使用"-Xlog-implicits"选项来调试"分散隐式扩展"错误.但是,它也会在与这些错误无关的地方记录大量含义.有没有办法限制它只能解释产生编译错误的地方?
public List<String> foo1() {
List<String> retval = bar();
if (retval == null)
return Collections.emptyList();
else
return retval;
}
public List<String> foo2() {
List<String> retval = bar();
return retval == null ? Collections.emptyList() : retval;
}
Run Code Online (Sandbox Code Playgroud)
为什么foo1()编译很好而foo2()有错误?(更准确地说"类型不匹配:无法从List <capture#1-of?extends Object>转换为List <String>")
我原以为这两个函数都会编译成相同的字节码,所以一个聪明的编译器应该推断出正确的类型emptyList()...
①在下面的C#代码中,出现了CS1729,但据我所知,CS0122更合适.
namespace A
{
class Program
{
static void Main()
{
Test test = new Test(1);
}
}
class Test
{
Test(int i) { }
}
}
Run Code Online (Sandbox Code Playgroud)
CS1729:'A.Test'不包含带有1个参数的构造函数
CS0122:'A.Test.Test(int)由于其保护级别而无法访问'
②在下面的C#代码中,出现CS0122,但据我所知CS1729更合适
namespace A
{
class Program
{
static void Main()
{
Test test = new Test();
}
}
class Test
{
Test(int i) { }
}
}
Run Code Online (Sandbox Code Playgroud)
CS0122:'A.Test.Test(int)由于其保护级别而无法访问'
CS1729:'A.Test'不包含带0参数的构造函数
问题:①和②中交换CS0122和CS1729是否有任何原因或者是这个C#编译器错误?
PS:可以使用Microsoft Visual C#2010编译器版本4.030319.1重现①和②中的错误.
我正试图在今晚向应用程序商店发布应用程序.我过去几个月一直在开发Xcode 6-Beta 2(仅限Objective-C),并且不知道你不能通过Xcode Beta提交.所以,我在普通Xcode中打开了项目,并在尝试重新存档项目时收到以下错误:
Compilation failed for data model at path '/Users/ME/Library/Developer/Xcode/DerivedData/ProjectDataFolder/Build/Products/Debug-iphoneos/Project.app/Model.momd/Model.mom'
我尝试删除派生数据,清理构建文件夹等标准的东西.我还尝试清理archives文件夹和模拟器应用程序文件夹.都没有奏效.但是,在Xcode Beta中重新打开应用程序是第一次尝试.回到Xcode,发生了同样的错误.
任何帮助都会非常感激.
上升到gradle 4.4之后:
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Run Code Online (Sandbox Code Playgroud)
Android项目编译失败,出现以下错误:
Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.1.2/manifest-merger-26.1.2.jar
Run Code Online (Sandbox Code Playgroud) compiler-errors ×10
c++ ×3
c# ×2
java ×2
.net ×1
android ×1
constructor ×1
core-data ×1
cygwin ×1
dapper ×1
generics ×1
gradle ×1
implicit ×1
ios ×1
java-7 ×1
maven ×1
namespaces ×1
object ×1
project ×1
protection ×1
scala ×1
scalac ×1
visual-c++ ×1