调试后出现项目加载错误
Project loaded error after debugging
EDIT:所以接受了你们的建议,现在我的程序正在编译。但现在我无法运行它,因为我遇到了这些错误。
'baseconverter.exe': Loaded 'C:UsersOwnerTDocumentsVisual Studio 2010
ProjectsbaseconverterDebugbaseconverter.exe', Symbols loaded.
'baseconverter.exe': Loaded 'C:WindowsSystem32ntdll.dll', Cannot find or open the PDB file
'baseconverter.exe': Loaded 'C:WindowsSystem32kernel32.dll', Cannot find or open the PDB file
'baseconverter.exe': Loaded 'C:WindowsSystem32KernelBase.dll', Cannot find or open the PDB file
'baseconverter.exe': Loaded 'C:WindowsSystem32msvcp100d.dll', Symbols loaded.
'baseconverter.exe': Loaded 'C:WindowsSystem32msvcr100d.dll', Symbols loaded.
The program '[5320] baseconverter.exe: Native' has exited with code 0 (0x0).
这是最新更新的代码。我修复了std::cout并删除了名称空间,但我认为这重载了编码。
转换器.h
#ifndef CONVERTER_H
#define CONVERTER_H
using std::cout;
using std::cin;
using std::endl;
//This contains the function types needed for
//reading an input
//converting from any base to base10
//convert from base10 to any base
extern int non10num;
extern int bIn;
extern int bOut;
extern int b10num;
extern int Conv;
extern int option;
extern int sum;
extern int num;
#endif
转换.cpp
#include <iostream>
#include <cmath>
#include <string>
#include <cctype>
#include "converter.h"
using std::cout;
using std::cin;
using std::endl;
int non10num = 0;
int bIn = 0;
int bOut = 0;
int b10num = 0;
int Conv = 0;
int option = 0;
int sum = 0;
int num = 0;
int main ()
{
//Reinstates the int variables
int pow = 1;
while (option)
{
sum += b10num * pow;
num /= 10;
pow *= non10num;
}
}
转换器.cpp
#include <iostream>
#include <cmath>
#include <string>
#include <cctype>
#include "converter.h"
using std::cout;
using std::cin;
using std::endl;
extern int non10num;
extern int bIn;
extern int bOut;
extern int b10num;
extern int Conv;
extern int option;
extern int sum;
extern int num;
//This brings us to the menu
void menu()
{
cout << "1. Base to Base" << endl;
cout << "2. Base to Base-10" << endl;
cout << "3. Base-10 to Base" << endl;
cout << "4. Exit" << endl;
cout << "" << endl;
cout << "Choose your option: ";
cin >> option;
switch (option)
{
case 1: cout << "Enter your integer: "; //Asks for user input
cin >> non10num;
cout << "Enter which base it belongs to: ";
cin >> bIn;
cout << "Enter the base it should be converter: ";
cin >> bOut;
cout << non10num << " in base " << bIn << " is " << non10num%bIn << " in base " << bOut<< endl; //Converts the data
break;
case 2: cout << "Enter your integer: ";
cin >> non10num;
cout << "Enter which base it belongs to: ";
cin >> bIn;
cout << non10num << " in base " << bIn << " is " << non10num%10 << " in " << b10num;
break;
case 3: cout << "Enter your integer: ";
cin >> b10num;
cout << "Enter which base the integer will be converted: "; cin >> Conv;
cout << b10num << " in base 10 is " << b10num%10 << " in "<< Conv;
break;
case 4: //Exits the menu
return ;
break;
default:
cout << "You have entered an invalid option!" << endl;
}
while (option!=0);
return ;
}
在一个的cpp文件中定义每个文件:
int bIn = 0;
然后在所有其他文件中这样声明:
extern int bIn;
就目前的情况来看,你违反了一个定义规则。
此外,现在,您正在main()
中声明相同名称的变量,这将隐藏该函数中的所有全局变量,这可能不是您想要的。
不要在任何文件中使用#include "convertion.cpp"
。通过包含它,您就用文件的内容替换了include行,所以您在同一个程序中声明了non10num
两次:一次在"converter.cpp"中(因为include行),一次在"conversion.cpp"中。我希望这会有所帮助。
相关文章:
- 为什么加载SDF会导致Mobilizer创建闭环错误
- C++atioglxx.pdb未加载错误glBufferData OpenGL
- 当我尝试加载内核模块时,如何修复C++中的这个 malloc() 错误?
- 在 Linux 中使用 -fvisibility=hidden 编译时出现库加载错误
- 视觉C++:图像序列加载错误
- SFML: dyld:即使更新了库路径,库也未加载错误
- 如何处理加载错误的共享库版本的情况
- SFML 库未加载错误,找不到图像
- C Excel加载加载错误:XLL文件由Excel加载为文本文件
- IF流 Fin 加载错误
- 示例文件中的CImg图像加载错误
- 如何修复C#应用程序中调用C++DLL函数时的上下文加载错误
- 使用 LoadLibraryA 的 dll 加载错误
- 关于赋值运算符过度加载错误
- 调试后出现项目加载错误
- 如何解决 clang 的 Python 绑定的加载错误?
- 从c++调用MATLAB dyld:库未加载错误
- 包编译动态库加载错误
- 尝试在Visual Studio 2012中编译时,符号加载错误
- OpenGL多重纹理加载错误