compiler-errors 相关问题

编译阶段生成的错误,通常是由于语法和/或类型无效的问题。与[runtime-error]比较。

为什么我的 Haskell 代码显示“变量不在范围内:main”?

当我在 repl.it 网站上的 Haskell 交互式 shell 中输入以下内容时,它运行得很好。 让 squareMe x = x * x 让 myFruit = ["香蕉", "苹果", "猕猴桃", "橙子"] 但当我打字时...

回答 4 投票 0

IntelliJ 无法解析我的库中的类

我使用这些 pom.xml 创建了一个库: 我用这些 pom.xml 创建了一个库: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>spring.boot</groupId> <artifactId>jwt</artifactId> <version>0.0.1</version> <name>jwt</name> <description>A library of the boilerplate configuration for securing a Spring Boot API with JWT </description> <properties> <java.version>21</java.version> </properties> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>0.11.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>0.11.5</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>0.11.5</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 我是通过mvn clean install打包的。然后,为了测试它,我将其添加到我的本地 Maven 存储库:~/.m2/repository,运行:mvn install:install-file -Dfile=jwt-0.0.1.jar -DgroupId=spring.boot -DartifactId=jwt -Dversion=0.0.1 -Dpackaging=jar,并将其包含在不同项目的 pom.xml 中,如下所示: <dependency> <groupId>spring.boot</groupId> <artifactId>jwt</artifactId> <version>0.0.1</version> </dependency> 但是,当我尝试使用库中的类时,IntelliJ 仍然显示 can't find symbol。 到目前为止我遇到的问题: 我已确认该库确实已保存到我本地的 Maven 存储库中 我已使缓存失效并重新启动了我的 IntelliJ 我还检查了我的 jar 的目录结构 我该如何解决这些问题? 转到:视图 -> 工具窗口 -> Maven 这对我有帮助。我认为IntelliJ有时不会自动更新内部库缓存。

回答 1 投票 0

Unity 框架单元测试未定义对“setUp”和“tearDown”的引用

我从 Unity for C 单元测试库复制了最简单的代码,并设置了一个非常基本的测试,我从网站复制并粘贴了该测试: #include“unity/src/unity.h” int 主函数(无效) { ...

回答 4 投票 0

当我尝试使用 g++ 进行编译并且使用 macOS 时,我收到有关构造函数的错误:没有匹配的构造函数用于初始化[关闭]

我有一个完全正常的代码(一个 cpp 和一个 cpp 文件)和一个 makefile,但是当我尝试用 g++ 编译它时,我得到这个: g++ -std=c++11 -c subject.cpp -o subject.o 在主题包含的文件中......

回答 1 投票 0

为什么我不能从声明为返回字符串的函数返回整数?

类解决方案{ 民众: 字符串 kthLargestNumber(向量& nums, int k) { 优先队列q; for(int i=0;i class Solution { public: string kthLargestNumber(vector<string>& nums, int k) { priority_queue<int>q; for(int i=0;i<nums.size();i++) { q.push(stoi(nums[i])); } while(!q.empty()) { k--; if(k==0) { return q.top(); } q.pop(); } return 0; } }; 我试图解决 Leetcode 1985. 找出数组中第 K 个最大整数的问题。但我在第 14 行遇到编译错误 (return q.top();) 我不知道为什么会发生这种情况。 问题链接 只要看一下代码,答案就很简单了。该函数应返回 std::string,而您则返回 和 int。您现在可能想通过使用 to_string 函数并将 int 转换为 std:string 来解决问题。 但是,这是行不通的。 该解决方案应该而且必须适用于字符串。 Constraints: 1 <= k <= nums.length <= 104 1 <= nums[i].length <= 100 nums[i] consists of only digits. nums[i] will not have any leading zeros. 很明显,你不能在int中存储100位长的数字。因此,您还必须使用字符串排序。 但这会让事情变得困难,因为你需要采用所谓的自然排序。 示例:查看 2,3 和 200,然后,如果您比较字符串,3 将大于 200。这就是他们想要从您那里得到的。自然排序。 有很多可能的解决方案。这是其中之一: #include <iostream> #include <string> #include <cctype> #include <algorithm> #include <vector> using namespace std::string_literals; // FUNCTOR for Natural sort function. Limited to signed char strings struct NaturalSort { bool operator ()(const std::string& s1, const std::string& s2) { // We want to iterate over both strings const char* i1 = s1.data(); // Get a pointer to the beginning of string 1 const char* i2 = s2.data(); // Get a pointer to the beginning of string 2 // Result of comparison. 0 means equal, positive means s1>s2, negative means s1<s2 int result = 0; // As long as both characters/numbers are equal and there are still characters in the string do { // If we found a digit at the same position in both strings if (std::isdigit(*i1) and std::isdigit(*i2)) { std::size_t pos1{}, pos2{}; // This will later indicate how many digits we read // Convert the strings to numbers and compare them result = std::stoi(i1, &pos1) - std::stoi(i2, &pos2); // Set pointers to the position after the number i1 += pos1; i2 += pos2; } else { // Normal character result = (*i1 - *i2); ++i1; ++i2; } } while ((result == 0) and (*i1 != 0 or *i2 != 0)); // Let's limit the output to -1, 0 ,1 return result < 0; } }; class Solution{ public: std::string kthLargestNumber(std::vector<std::string>& nums, int k) { std::sort(nums.begin(), nums.end(), NaturalSort()); return nums[nums.size()-k]; } }; // Driver / test code int main() { std::vector<std::string> test{ "2"s,"3"s,"20"s,"30"s,"200"s,"300"s }; Solution solution{}; for (int k = 1; k <= test.size(); ++k) std::cout << "With k=" << k << " the result would be: " << solution.kthLargestNumber(test, k) << '\n'; }

回答 1 投票 0

为什么 stoi() 函数在以下代码中不起作用?

类解决方案{ 民众: 字符串 kthLargestNumber(向量& nums, int k) { 优先队列q; for(int i=0;i class Solution { public: string kthLargestNumber(vector<string>& nums, int k) { priority_queue<int>q; for(int i=0;i<nums.size();i++) { q.push(stoi(nums[i])); } while(!q.empty()) { k--; if(k==0) { return q.top(); } q.pop(); } return 0; } }; 我试图解决 Leetcode 1985. 找出数组中第 K 个最大整数的问题。但我在第 14 行遇到编译错误( return q.top(); ),我不知道为什么会发生这种情况。 问题链接 只要看一下代码,答案就很简单了。该函数应返回 std::string,而您则返回 和 int。您现在可能想通过使用 to_string 函数并将 int 转换为 std:string 来解决问题。 但是,这是行不通的。 该解决方案应该而且必须适用于字符串。 Constraints: 1 <= k <= nums.length <= 104 1 <= nums[i].length <= 100 nums[i] consists of only digits. nums[i] will not have any leading zeros. 很明显,你不能在int中存储100位长的数字。因此,您还必须使用字符串排序。 但这会让事情变得困难,因为你需要采用所谓的自然排序。 示例:查看 2,3 和 200,然后,如果您比较字符串,3 将大于 200。这就是他们想要从您那里得到的。自然排序。 有很多可能的解决方案。这是其中之一: #include <iostream> #include <string> #include <cctype> #include <algorithm> #include <vector> using namespace std::string_literals; // FUNCTOR for Natural sort function. Limited to signed char strings struct NaturalSort { bool operator ()(const std::string& s1, const std::string& s2) { // We want to iterate over both strings const char* i1 = s1.data(); // Get a pointer to the beginning of string 1 const char* i2 = s2.data(); // Get a pointer to the beginning of string 2 // Result of comparison. 0 means equal, positive means s1>s2, negative means s1<s2 int result = 0; // As long as both characters/numbers are equal and there are still characters in the string do { // If we found a digit at the same position in both strings if (std::isdigit(*i1) and std::isdigit(*i2)) { std::size_t pos1{}, pos2{}; // This will later indicate how many digits we read // Convert the strings to numbers and compare them result = std::stoi(i1, &pos1) - std::stoi(i2, &pos2); // Set pointers to the position after the number i1 += pos1; i2 += pos2; } else { // Normal character result = (*i1 - *i2); ++i1; ++i2; } } while ((result == 0) and (*i1 != 0 or *i2 != 0)); // Let's limit the output to -1, 0 ,1 return result < 0; } }; class Solution{ public: std::string kthLargestNumber(std::vector<std::string>& nums, int k) { std::sort(nums.begin(), nums.end(), NaturalSort()); return nums[nums.size()-k]; } }; // Driver / test code int main() { std::vector<std::string> test{ "2"s,"3"s,"20"s,"30"s,"200"s,"300"s }; Solution solution{}; for (int k = 1; k <= test.size(); ++k) std::cout << "With k=" << k << " the result would be: " << solution.kthLargestNumber(test, k) << '\n'; }

回答 1 投票 0

解析不起作用:在抛出“std::invalid argument”实例后调用终止

我想要一个返回 2 个整数向量的函数。输入是一个字符串。 插入的字符串的布局应始终如下所示:“COORDINATES 123 456”,带有

回答 1 投票 0

VS代码html5样板“未知单词(CssSyntaxError)stylelint(CssSyntaxError)”

在此处输入图像描述,我的 html 样板 VScode 中显示一条红线。当我将鼠标悬停在它上面时会显示此内容(未知单词(CssSyntaxError)stylelint(CssSyntaxError)。 初级水平的东西...

回答 2 投票 0

当我尝试使用 g++ 编译时出现此错误

我有一个完全正常的代码(一个 cpp 和一个 cpp 文件)和一个 makefile,但是当我尝试用 g++ 编译它时,我得到这个: g++ -std=c++11 -c subject.cpp -o subject.o 在主题包含的文件中......

回答 1 投票 0

Visual Studio 代码概念不起作用

我正在学习C++。并致力于 Visual Studio 代码。但每当我尝试使用 #include 时,它都会给我错误。就像我创建模板概念 xyz = require(T t){} 时一样

回答 1 投票 0

如何将仅限 init 的属性的值传播到封闭类?

我有一个 Wheel 类,它具有仅限 init 的属性 Spokes: 公开课轮 { 内部轮子() { } 公共 int 辐条 { 得到;在里面; } } 这对于此类的功能至关重要...

回答 1 投票 0

Qt 不允许使用不完整类型

我正在尝试用qt制作一个简单的GUI。我想要一个 ChooseModeGUI 窗口,我可以在其中选择(单击 2 个按钮中的 1 个)并选择一种模式。 我拥有的文件是: 选择模式GUI.ui 管理员G...

回答 1 投票 0

如何使用 C++ enum+switch 语句进行详尽的编码

问题: 当我没有为类型的每个可能值包含分支时,如何让编译器警告我?当我使用可能获得值的类型进行编码时,这一点尤其重要

回答 1 投票 0

显示方法未在主JAVA中编译

我不知道如何从形状类调用显示方法到Main方法。这是一个作业,我们不应该改变 Main 中写的内容,所以问题就来了......

回答 1 投票 0

GLFW 和 GLEW 的问题

当我学习 C 和 C++ 时,我开始使用 SDL2 来可视化我正在编写的程序。我使用 Visual Studio Code,因为我喜欢它的外观,而且我不想使用 IDE,我使用 com...

回答 1 投票 0

C++ 没有“splashkit.h”头文件的文件或目录

我一直在尝试修复我的一个程序的一些构建问题,并且似乎遇到了与使用头文件构建我的程序有关的错误。 每当我尝试包含“splas...

回答 1 投票 0

使用带有列表初始化的指定初始化器时,类模板参数推导失败

在初始化结构模板实例时,使用大括号 init 语法和指定的初始值设定项时,编译器(GCC 和 Clang)会出错。 这里: 模板 是...

回答 1 投票 0

Visual Studio 2015:C++ 代码分析错误 C1253,无法加载模型文件“res://mspft140.dll/300”

Visual Studio 2015 Community update 3,尝试C++代码分析功能。设置如下: 解决方案属性 > 代码分析设置 > [所有配置] [所有平台] :

回答 1 投票 0

clang-tidy 找不到头文件

我正在 bazel 项目上运行 clang-tidy。我使用看似有效的命令生成了compile_commands.json。 我正在运行,如下所示: clang-tidy -p /path/to/compile_commands.json /

回答 1 投票 0

如何解决。错误:(-215) !empty() 函数中的 detectorMultiScale

你好,我有“错误:(-215)!empty()函数中的DetectMultiScale” xml = './haarcascade_hand.xml' face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + xml) 该代码不起作用......

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.