当ARM Cortex-M3的GCC 4.7.3(20121207)获取函数的地址时,它无法获得函数的确切地址.我可以在那个指针中看到一个一个接一个.
// assume at address 0x00001204;
int foo() {
return 42;
}
void bar() {
int(*p)() = &foo; // p = 0x1205;
p(); // executed successfully
foo(); // assembly: "bl 0x00001204;"
}
Run Code Online (Sandbox Code Playgroud)
虽然指针指向奇数地址,但执行成功.我希望在这一点上有一个例外.为什么需要那个奇怪的地址以及它为什么不会受到伤害.
编辑
我写了以下示例代码来演示我的问题
#include <iostream>
#include <string.h>
using namespace std;
void f (char*** a)
{
*a = new (char*[2]);
*a[0] = new char[10];
*a[1] = new char[10];
strcpy(*a[0], "abcd");
strcpy(*a[1],"efgh");
}
int main ()
{
char** b = NULL;
f(&b);
cout<<b[0]<<"\n";
cout<<b[1]<<"\n";
return 1;
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中我发现a = new(char [2]); 不分配*a [1]的内存.
在gdb中我得到了以下seg错误.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400926 in f (a=0x7fffffffdfe8) at array1.cpp:10
10 *a[1] = new char[10];
(gdb) p *a[1]
Cannot access memory at address 0x0
Run Code Online (Sandbox Code Playgroud)
这真让我困惑.有人可以解释我哪里出错了.
我知道我可以传递像void f(char**&a)这样的参数,并通过调用函数f(b)来实现.但我想知道如果我使用char***a想要发生的事情.它也应该工作.对不起,如果这是一个愚蠢的问题. …
WiX 安装程序产品节点有一个属性UpgradeCode。它用于指代同一产品的先前版本。该值存储在UpgradeTable中。UpgradeTable 由FindRelatedProducts操作进行解析。
允许UpgradeCode删除具有相同的以前的产品UpgradeCode。但计划是将几个过时的遗留产品集成到一个组合的单一产品中。UpgradeCode该遗留产品的特征是已知的。我希望将此代码添加到 UpgardeTable 中也能删除此遗留产品。这可以通过填充 UpgradeTable 来完成。
如何在 WiX 设置的升级表中添加更多条目?
编辑:需要什么语法?
有没有更好的方法来删除升级后废弃的产品?
我有一个安装程序来安装Windows服务.此安装程序包含一个UI对话框,允许用户指定服务名称.此服务名称存储在公共属性中.安装程序成功创建具有指定名称的服务,但是当我尝试卸载它时,安装程序会尝试停止并删除具有默认服务名称属性(未由用户指定)的服务.
我的服务安装代码如下所示:
...
<Property Id="SERVICE_NAME" Value="Default_Service_Name" />
...
<Component Id="C.service.exe" Guid="...">
<File Id="service.exe" Name="$(var.service.TargetFileName)" KeyPath="yes" Vital="yes"
Source="$(var.service.TargetPath)" />
<ServiceInstall Id="MyServiceInstall" DisplayName="[SERVICE_NAME]" Account="[SERVICE_ACCOUNT]" Password="[SERVICE_PASSWORD]"
Name="[SERVICE_NAME]" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes">
</ServiceInstall>
<ServiceControl Id="MyServiceStart" Name="[SERVICE_NAME]" Start="install" Wait="no" />
<ServiceControl Id="MyServiceStop" Name="[SERVICE_NAME]" Stop="both" Wait="yes" />
<ServiceControl Id="MyServiceRemove" Name="[SERVICE_NAME]" Remove="uninstall" Wait="yes" />
</Component>
...
Run Code Online (Sandbox Code Playgroud)
在用户指定服务名称后,我可能需要一些CA来更新SerciceControl表吗?
尝试在运行QT5.4的Windows平台上用x86和x86_64编译VS2010,VS2012的开源项目.
名为unit.h的文件包含一个部分:
[...]
// DO NOT change noscale's value. Lots of assumptions are made based on this
// value, both in the code and (more importantly) in the database.
enum unitScale
{
noScale = -1,
extrasmall = 0,
small = 1, // Line that causes errors.
medium = 2,
large = 3,
extralarge = 4,
huge = 5,
without = 1000
};
[...]
Run Code Online (Sandbox Code Playgroud)
生成
我试着用我的帽子解决它.我删除了代码中"小"枚举的每一次使用,我仍然得到错误.但在删除了所有用途后,我将"small"重命名为"smallo",一切都很好.它似乎表示名称冲突,但文件搜索在整个项目中没有给我任何引用.这不是我所知道的任何关键词.
有什么想法吗?
编辑:感谢非常有用的评论这里是一个更奇怪的版本,有效.有人可以解释一下吗?
#ifdef small // Same with just straight …Run Code Online (Sandbox Code Playgroud) 我在 Rstudio 中使用 bookdown 编译了一个简短的文档。我只想删除文档开头的目录。我可以“编织到 pdf”而不是“编织到 pdf_book”或“编织到 pdf_document2”,但是这样会丢失很多 bookdown 功能(交叉引用等)。
应该很容易吧?
//C++ Made Easy HD 26 - Introduction to Classes
//Michael LeCompte
#include <iostream>
#include <string>
using namespace std;
class Player {
public:
Player() {
cout << "1st overload" << endl;
}
Player(int Health){
cout << "2nd overload" << endl;
this->health = Health;
}
Player(int Health, int attPow){
cout << "3nd overload" << endl;
this->health = Health;
attackPower = attPow;
}
~Player() {
cout << "Player instance destroyed" << endl;
}
//Mutators
void setHealth(int val) {
health = val;
}
void …Run Code Online (Sandbox Code Playgroud) 这是我的代码
#include "stdafx.h"**
class IPlayback
{
public:
virtual void createRenderStream() = 0;
};
class ICapture
{
public:
virtual void createCaptureStream() = 0;
};
class IAudioStackInterface
{
public:
virtual void createStream() = 0;
};
class CAudioClientInterface : public IAudioStackInterface,
public ICapture,
public IPlayback
{
void createCaptureStream()
{
printf("\n i am in createCaptureStream");
}
void createRenderStream()
{
printf("\n i am in createRenderStream");
}
void createStream()
{
printf("\n i am in createStream");
}
};
typedef IAudioStackInterface* PIAudioStackInterface;
typedef ICapture* PCapture;
typedef IPlayback* PIPlayback; …Run Code Online (Sandbox Code Playgroud) 我现在正在编写用于图像处理的小应用程序.但是我的程序内存使用存在很大问题.我是c ++的新手,以前我主要用c#编程.
几乎所有工作的功能都是这样的
while(!prototypeVector[i]->GetIsConvergaed())
{
if(previousPrototype!=NULL) delete previousPrototype;
previousPrototype = prototypeVector[i]->CopyPrototype();
if(&matchingPointVector!=NULL) matchingPointVector.clear();
matchingPointVector = prototypeVector[i]->CalculateMatchingPointsAll(imageDataVector);
distanseMatrix = CalculateDistanceAll(i);
membershipMatrix = UpdateMembershipAll(i);
if(translation)
{
tmatrix = UpdateTranslationMatrix(i);
if(directUpdate) prototypeVector[i]->SetTranslationMatrix( tmatrix);
//prototypeVector[i]->GetTranslationMatrix().DisplayMatrix();
tmatrix.DisplayMatrix();
}
if(scaling)
{
smatrix = UpdateScalingMatrix(i);
if(directUpdate) prototypeVector[i]->SetScalingMatrix(smatrix);
smatrix.DisplayMatrix();
}
if(rotation)
{
angle = UpdateAngleCoefficient(i);
cout<<endl;
Convert::RadiansToDegrees(angle)<<endl;
if(directUpdate)prototypeVector[i]->UpdateRotationMatrix(angle);
}
prototypeVector[i]->TransformTemplateOne(prototypeVector[i]->GetRotationMatrix(), prototypeVector[i]->GetScalingMatrix() , prototypeVector[i]->GetTranslationMatrix());
}
Run Code Online (Sandbox Code Playgroud)
我注意到如果在上面写的函数被称为另一个函数
CalculateMatchingPointsAll或CalculateDistanceAll或UpdateScalingMatrix内存使用率大幅上升(执行上述每个函数后300kB).所以我认为问题出在这些功能上.他们看起来像那样
vector<Point*> TemplateClusterPoint::CalculateMatchingPointsAll( vector<Point*> imageDataVector)
{
vector<Point*> matchinPointVector = vector<Point*>(imageDataVector.size(),new Point(0,0));
double minValue = DOUBLE_MAX_VALUE;
double currentDistance = 0;
for (int i=0;i<imageDataVector.size();i++ ) …Run Code Online (Sandbox Code Playgroud) 我正在宣布这样一个类:
#include "BindableInterface.h"
#include "../LuaHelper.h"
#include <map>
#include <string>
namespace utils{
class CLuaHelper;
};
namespace zel{
namespace utils{
class CAPIBindManager
{
typedef std::map<std::string, CBindeableInterface*> t_exposedClassMap;
t_exposedClassMap m_classesToExpose;
utils::CLuaHelper* m_luaHelper;
public:
bool exportClasses(const unsigned char* data);
bool executeLuaChunk(const std::string fileName, const std::string funtionName);
bool addClassToExpose(CBindeableInterface* bindableInterface, const std::string alias);
CAPIBindManager(void);
~CAPIBindManager(void);
};
};
};
Run Code Online (Sandbox Code Playgroud)
但是我得到了一个编译错误,CLuaHelper不是zel :: utils的成员.CLuaHelper声明为utils :: CLuaHelper(没有zel)我如何声明这个类.AFAIK,前瞻性声明可能会解决这个问题
有任何想法吗??
我想在我的新笔记本电脑上安装GitExtensions.Microsoft更新已在计算机上安装了.NET Framework客户端配置文件.但是GitExtensions安装程序抱怨说,没有安装.NET Framework.
这是一个类似.NET 3.5问题的类似问题吗?如何避免在Microsoft .NET Framework 4客户端配置文件之外另外安装Microsoft .NET Framework 4 ?它们的大小相似,我想我不需要两者.
template<typename T>
class vector {
vector();
vector(const vector& c);
vector(size_t num, const T& val = T());
~vector();
T& operator[](size_t index);
const T& operator[](size_t index) const;
vector operator=(const vector& v);
T& at(size_t loc);
const T& at(size_t loc) const;
void pop_back();
void push_back(const T& val);
size_t size() const;
};
Run Code Online (Sandbox Code Playgroud) 我编写了一个显示来自通信线路的数据的模块。它应在十六进制转储中显示传输的数据。
如何将列表转换a=[0x41,0x42,0x43,0x0D]为十六进制转储,如
41 42 43 0D ABC.
Run Code Online (Sandbox Code Playgroud)
请注意,不可打印的字符被替换为点。
我用''.join(map(chr,a)). 这在 Python shell 中显示为 'ABC\n',但这仍然包括换行符。
在另一种方法中,我想完全按照 Python shell 中显示的方式显示列表到输出。即换行应显示为“\n”,而不是转到下一行。如何\n用点\\n替换任何其他不可打印的字符?