だから私はcl_Pageクラスを持っています:
class cl_Page{
public:
cl_Page(cl_LessonMoment *parent_param);
cl_Page(cl_SoftRoot *parent_param);
int parent_type;
cl_LessonMoment *parent_lmoment;
cl_SoftRoot *parent_softroot;
char id[256];
//<content>
//Backgrounds.
str_Color bgcolor;
cl_Image bgimage;
//Actual content
vector<cl_Textbox> textboxes;
vector<cl_Button> buttons;
vector<cl_Image> images;
//</content>
cl_Textbox* AddTextbox();
cl_Button* AddButton();
cl_Image* AddImage(char *filename = nullptr);
};
およびcl_Pageコンストラクター:
cl_Page::cl_Page(cl_LessonMoment *parent_param) : bgimage(nullptr){ //here is the segfault
parent_lmoment = parent_param;
parent_type = 1;
id[0] = '\0';
SetColor(bgcolor, 0xffffffff);
}
cl_Page::cl_Page(cl_SoftRoot *parent_param): bgimage(nullptr){ // or here if i call this constructor
/*parent_softroot = parent_param;
parent_type = 2;
id[0] = '\0';
SetColor(bgcolor, 0xffffffff);*/
}
何が起こるかというと、コンストラクターをどのように呼び出しても、またはどのコンストラクターを呼び出しても(2番目はすべてコメント化されているため、基本的に空です)、関数内またはメンバーオブジェクトとして、グローバル、ローカル、または動的に、次のようになります。線上にあるように見えるセグメンテーション違反cl_Page::cl_Page(cl_LessonMoment *parent_param) : bgimage(nullptr){
。呼び出しスタックは次のようになります。
#0 77C460CB strcat() (C:\WINDOWS\system32\msvcrt.dll:??)
#1 0022F168 ?? () (??:??)
#2 00401905 cl_Page::cl_Page(this=0x22fbe8, parent_param=0x0) (F:\Scoala\C++\EduSoftViewer_Parser\sources\classes\soft_tree\page.cpp:10)
#3 00402B8A main() (F:\Scoala\C++\EduSoftViewer_Parser\sources\main.cpp:11)
これを書く前のいくつかのビルドでは、(まったく同じ問題で)コールスタックの#1の位置(現在は)?? () (??:??)
でしたntdll!RtlDosApplyFileIsolationRedirection_Ustr() (C:\WINDOWS\system32\ntdll.dll:??)
。
だから私の質問は:誰かがこれを引き起こしているものを知っていますか?私は本当にこれを機能させる必要があります。
不明な点がある場合は、質問してください。追加情報を提供します。
編集:明確にするために:私はWindows XP SP2を使用しており、gccでCode::Blocksを実行しています。
編集2:cl_Imageコンストラクター:
cl_Image::cl_Image(char *filename_param){
if (filename == nullptr){
filename[0] = '\0';
}
else{
strcpy(filename, filename_param);
}
SetPosition(position, 0, 0);
id[0] = '\0';
visible = 1;
z_index = 0;
}
このクラスには、POD構造体を除いて、オブジェクトメンバーは含まれていません。position
編集3:cl_Imageクラス:
class cl_Image{
public:
cl_Image(char* filename_param = nullptr);
str_Position position;
char filename[256];
char id[256];
bool visible;
int z_index;
};
str_Position
2intの構造体です。