|
Remove the CString dependency (i.e. use std::string or something else)... as easy CString is to use, they sure jumbled things up by essentially including it in two places (which is what I assume the link time portion means). Now, I am assuming that's what they mean by "not being link-time compatible" means. You can verify by using a tools to look for the CString symbols in either library (in linux you'd use the "nm" utility, there must be a Windows equivalent but not sure of the name).
|
|
|
|
|
i am getting error
error : expected unqualified-id
public ref class Form1 : public System::Windows::Forms::Form
^
error : expected unqualified-id
[STAThreadAttribute]
^
error : use of undeclared identifier 'STAThreadAttribute'
[STAThreadAttribute]
^
3 errors generated.
i am using clang compiler to build the project
what could be the possible reasons for this? How could I solve this?
thanks
|
|
|
|
|
Check the preceding lines to see if there is an incomplete statement.
|
|
|
|
|
there is only pragma and namespace above the error-ed public keyword-
#pragma once
namespace test4 {
namespace System{};
namespace System{namespace ComponentModel{}};
namespace System{namespace Collections{}};
namespace System{namespace Windows{namespace Forms{}}};
namespace System{namespace Data{}};
namespace System{namespace Drawing{}};
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
error is not shown above the public keyword
I had replaced-
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
with
namespace System{};
namespace System{namespace ComponentModel{}};
namespace System{namespace Collections{}};
namespace System{namespace Windows{namespace Forms{}}};
namespace System{namespace Data{}};
namespace System{namespace Drawing{}};
because i was getting error with the first one.
|
|
|
|
|
Those changes are completely wrong. You have removed the using keywords, and added lots of unnecessary brace characters. I suggest you create a new clean Form project from the Visual Studio templates.
|
|
|
|
|
Hi,
If I use using then I get the following errors-
error : expected namespace name
using namespace System; ^
error : use of undeclared identifier
using namespace System::ComponentModel;
^
error : expected namespace name
using namespace System::ComponentModel;
^
error : use of undeclared identifier
using namespace System::Collections;
^
and so on....including buttons...
So, I used the namespace with curly braces{} suggested somewhere on the net
Using that I don't get these errors but then I have trouble with Public keyword.
what can I do? Is clang compiler doing this?
|
|
|
|
|
VScoder12 wrote: So, I used the namespace with curly braces{} suggested somewhere on the net Don't. Using information from the internet without knowing what you are doing is not the way to get your program to work.
I am beginning to suspect that you are not using the CLR option on your project, so the compiler thinks this is unmanaged C++. Check your settings again.
|
|
|
|
|
I used Visual C++ > CLR > Windows Forms Application in my project creation
I think it is not recognizing the System namespace
If I use curly braces i think it recognizes System namespace but then it does not recognize the Private keyword
any suggestion?
|
|
|
|
|
VScoder12 wrote: any suggestion? Not really. I have just created a new Windows Forms application using Visual C++ 2010 Express, and it creates the correct files, and compiles without error. I can only assume that something is missing from your Visula Studio setup that causes these errors. The generated code of the two main files is as follows, you could try it in your system.:
#pragma once
namespace WinForm {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private:
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"Form1";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
}
#include "stdafx.h"
#include "Form1.h"
using namespace WinForm;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
|
|
|
|
|
if i use win32 then mine also compile and runs successfully
but i am having trouble with compiling/building with clang compiler as mentioned earlier
|
|
|
|
|
Clang doesn't support C++/CLI, while Microsoft's compilers do. That's the issue.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
VScoder12 wrote: clang compiler What is that, and what does it have to do with Visula Studio?
|
|
|
|
|
Clang Compiler[^]
An open-source compiler.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Yeah, I missed the significance of that in the opening question.
|
|
|
|
|
|
I implemented a multi language UI in a MFC program, since only a few controls, so I write translation in code, I knew it can be implemented with DLL, or String Table.
Now I wonder what way is better, in code, string table, or DLL,according to run time performance and space consuming.
|
|
|
|
|
If your program isn't huge, no reason to do this in an external library, that would definitely be the slowest and most (disk) space consuming method.
I'd say string table would probably be fast, and as long as you don't have too many strings, it shouldn't be too costly. If you have a huge number of strings, you may start using up quite a bit of memory to support this, then the library method starts to become more appealing.
|
|
|
|
|
Hello everyone,
I meet a crash problem. just as following, I donot know why IsWindow will crash,
Is there anyone meet the same problem?
AULTING_IP:
user32!IsWindow+1a
761a7150 8365fc00 and dword ptr [ebp-4],0
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 761a7150 (user32!IsWindow+0x0000001a)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: fffffffc
Attempt to write to address fffffffc
ChildEBP RetAddr Args to Child
06f9ff48 72d229bb 04e73a50 6928d287 00000000 user32!IsWindow+0x1a
06f9ff80 72d22a47 00000000 7710338a 04e74990 msvcr80!_callthreadstartex+0x1b [f:\sp\vctools\crt_bld\self_x86\crt\src\threadex.c @ 348]
06f9ff88 7710338a 04e74990 06f9ffd4 776b9f72 msvcr80!_threadstartex+0x66 [f:\sp\vctools\crt_bld\self_x86\crt\src\threadex.c @ 326]
06f9ff94 776b9f72 04e74990 70af11ab 00000000 kernel32!BaseThreadInitThunk+0xe
06f9ffd4 776b9f45 72d229e1 04e74990 00000000 ntdll!__RtlUserThreadStart+0x70
06f9ffec 00000000 72d229e1 04e74990 00000000 ntdll!_RtlUserThreadStart+0x1b
|
|
|
|
|
Please show the code that causes the error, it looks as if you are passing a bad parameter to some windows function.
|
|
|
|
|
Further questions:
- the window handle you feed into IsWindow: is it a handle inside your application or a different window?
- is your application running elevated?
- is the other application running elevated?
- are there differences in 32 vs. 64bit architecture between the applications?
|
|
|
|
|
Windows XP, Visual Studio 2008, MFC, Cpp
Note: I am hoping that someone recognizes this basic class of problems and can advise me without additional details. If needed, tell me what additional details are required.
I cannot copy/paste from my working computer so please excuse any obvious typos.
Basic Problem:
I added a simple stand alone function to my project and cannot get Visual Studio to compile it.
Setup:
Application AR2_IADS_Client_Simlulator is located in E:\VISUAL_STUDIO\AR2_IADS_Client_Simulator.
This directory: E:\VISUAL_STUDIO\COMMON_CODE contains classes and code that is used by multiple solutions and projects.
In the Solution Explorer, project AR2_IADS_Client_Simulator I right clicked on the Header Files part of the project and added a new dot h file named: Log_One_TCP_Packet.h. It was placed in the COMMON_CODE directory. It looks like this:
#include "stdafx.h"
#include "C_Log_Writer.h"
Void Log_One_TCP_Packet( … arguments );
The same was done in section Source Files and file Log_One_TCP_Packet.h.cpp was also created in COMMON_CODE. It begins like this:
#include "stdafx.h"
#include "Log_One_TCP_Packet.h"
Void Log_One_TCP_Packet( … arguments )
{ … }
Action:
The cpp file is open in VS and is in focus. Press ctl-F7 to compile it.
The error messages state:
Quote: Warning C4627 #include “stdafx.h” skipped when looking for precompiled header use.
Warning C4627 #include “Log_One_TCP_Packet.h” skipped when looking for precompiled header use.
Fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “stdafx.h”’ to your soruce?
I don’t know of any option such as: #include_and_do_not_skip “Log_One_TCP_Packet.h”
There is no button I can select that says: “No! I did not forget. Its right there in the source code.”
There are already several classes in COMMON_CODE used by this project. The directory is referenced in
Quote: Properties -> Configuration Properties -> C/C++ -> Additional Include Directories.
Questions
Must this function be made into a stand-alone class just for this one function?
How might I get VS to recognize and compile it?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Did you try cleaning and rebuilding the whole project?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Rats. Its so easy to forget the easy stuff. No, I did not. I will try that at work tomorrow. But I did make a class out of it and that worked just fine.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
IIRC you get this - or at least a similar - chain of warnings/errors when your first include does not match the precompiled header setting for the file.
Check that the precompiled header setting for this file actually is "stdafx.h", not another one.
|
|
|
|
|
I'm stuck here on how to compile the following code, i need to put a struct which contains std::unique_ptr into std::map, but i always get the error message, anybody can help me?
Quote: e:\console.cpp(21): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
1> with
1> [
1> _Ty=int
1> ]
1> d:\programfiles\vs 2010\vc\include\memory(2347) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'
1> with
1> [
1> _Ty=int
1> ]
1> This diagnostic occurred in the compiler generated function 'Baa::Baa(const Baa &)'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.28
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
here is my code:
#include <iostream>
#include <memory>
#include <vector>
#include <map>
struct Baa {
std::unique_ptr<int> x;
Baa() {
}
Baa(Baa&& o)
{
x = std::move(o.x);
}
Baa operator = (Baa&& param)
{
x = std::move(param.x);
return *this;
}
};
int main()
{
std::map<int, Baa> sheep;
Baa ba;
sheep[0] = ba;
}
|
|
|
|