Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. visual studio 2010 error help needed

visual studio 2010 error help needed

Scheduled Pinned Locked Moved ATL / WTL / STL
helpcsharpvisual-studioquestion
14 Posts 4 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VScoder12
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • V VScoder12

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Check the preceding lines to see if there is an incomplete statement.

      V 1 Reply Last reply
      0
      • L Lost User

        Check the preceding lines to see if there is an incomplete statement.

        V Offline
        V Offline
        VScoder12
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • V VScoder12

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          V 1 Reply Last reply
          0
          • L Lost User

            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.

            V Offline
            V Offline
            VScoder12
            wrote on last edited by
            #5

            Hi, If I use using then I get the following errors-

            error : expected namespace name
            using namespace System; ^
            error : use of undeclared identifier 'System'
            using namespace System::ComponentModel;
            ^
            error : expected namespace name
            using namespace System::ComponentModel;
            ^
            error : use of undeclared identifier 'System'
            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?

            L 1 Reply Last reply
            0
            • V VScoder12

              Hi, If I use using then I get the following errors-

              error : expected namespace name
              using namespace System; ^
              error : use of undeclared identifier 'System'
              using namespace System::ComponentModel;
              ^
              error : expected namespace name
              using namespace System::ComponentModel;
              ^
              error : use of undeclared identifier 'System'
              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?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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.

              V H 2 Replies Last reply
              0
              • L Lost User

                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.

                V Offline
                V Offline
                VScoder12
                wrote on last edited by
                #7

                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?

                L 1 Reply Last reply
                0
                • V VScoder12

                  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?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  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.:

                  // Form1.h
                  #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;
                  
                  /// /// Summary for Form1
                  /// 
                  public ref class Form1 : public System::Windows::Forms::Form
                  {
                  public:
                      Form1(void)
                      {
                          InitializeComponent();
                          //
                          //TODO: Add the constructor code here
                          //
                      }
                  
                  protected:
                      /// /// Clean up any resources being used.
                      /// 
                      ~Form1()
                      {
                          if (components)
                          {
                              delete components;
                          }
                      }
                  
                  private:
                      /// /// Required designer variable.
                      /// 
                      System::ComponentModel::Container ^components;
                      
                      #pragma region Windows Form Designer generated code
                      /// /// Required method for Designer support - do not modify
                      /// the contents of this method with the code editor.
                      /// 
                      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
                  };
                  

                  }

                  // WinForm.cpp : main project file.

                  #include "stdafx.h"
                  #include "Form1.h"

                  using namespace WinForm;

                  [STAThreadAttribute]
                  int main(array ^args)
                  {
                  // Enabling Windows XP visual effects before any controls are created
                  Application::EnableVisualStyles();
                  Application::SetCompatibleTextRenderingDefault(false);

                  // Create the main window and run it
                  Application::Ru
                  
                  V 1 Reply Last reply
                  0
                  • L Lost User

                    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.:

                    // Form1.h
                    #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;
                    
                    /// /// Summary for Form1
                    /// 
                    public ref class Form1 : public System::Windows::Forms::Form
                    {
                    public:
                        Form1(void)
                        {
                            InitializeComponent();
                            //
                            //TODO: Add the constructor code here
                            //
                        }
                    
                    protected:
                        /// /// Clean up any resources being used.
                        /// 
                        ~Form1()
                        {
                            if (components)
                            {
                                delete components;
                            }
                        }
                    
                    private:
                        /// /// Required designer variable.
                        /// 
                        System::ComponentModel::Container ^components;
                        
                        #pragma region Windows Form Designer generated code
                        /// /// Required method for Designer support - do not modify
                        /// the contents of this method with the code editor.
                        /// 
                        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
                    };
                    

                    }

                    // WinForm.cpp : main project file.

                    #include "stdafx.h"
                    #include "Form1.h"

                    using namespace WinForm;

                    [STAThreadAttribute]
                    int main(array ^args)
                    {
                    // Enabling Windows XP visual effects before any controls are created
                    Application::EnableVisualStyles();
                    Application::SetCompatibleTextRenderingDefault(false);

                    // Create the main window and run it
                    Application::Ru
                    
                    V Offline
                    V Offline
                    VScoder12
                    wrote on last edited by
                    #9

                    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

                    B L 2 Replies Last reply
                    0
                    • V VScoder12

                      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

                      B Offline
                      B Offline
                      Brisingr Aerowing
                      wrote on last edited by
                      #10

                      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???

                      1 Reply Last reply
                      0
                      • V VScoder12

                        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

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        VScoder12 wrote:

                        clang compiler

                        What is that, and what does it have to do with Visula Studio?

                        B 1 Reply Last reply
                        0
                        • L Lost User

                          VScoder12 wrote:

                          clang compiler

                          What is that, and what does it have to do with Visula Studio?

                          B Offline
                          B Offline
                          Brisingr Aerowing
                          wrote on last edited by
                          #12

                          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???

                          L 1 Reply Last reply
                          0
                          • B Brisingr Aerowing

                            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???

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #13

                            Yeah, I missed the significance of that in the opening question.

                            1 Reply Last reply
                            0
                            • L Lost User

                              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.

                              H Offline
                              H Offline
                              HighClassAsianEscort
                              wrote on last edited by
                              #14

                              [High Class Asian Escort](http://www.independentasianangels.co.uk/)

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups