Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:09:19+00:00 2026-05-27T07:09:19+00:00

Why C++/CLI compiler can compile this code: using namespace System; inline void Assembly(){ __asm{

  • 0

Why C++/CLI compiler can compile this code:

using namespace System;

inline void Assembly(){

__asm{
mov eax,5
}

}

int main(array<System::String ^> ^args)
{

    Assembly();
    Console::WriteLine(L"Hello World");
    return 0;
}

And can NOT for this one:

using namespace System;


int main(array<System::String ^> ^args)
{

__asm{
mov eax,5
}
    Console::WriteLine(L"Hello World");
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:09:20+00:00Added an answer on May 27, 2026 at 7:09 am

    The C++/CLI compiler supports generating both machine code and IL. It will generate machine code for any code that is compiled without /clr in effect or functions that are bracketed with #pragma managed(push, off) and #pragma managed(pop). Or functions that must be compiled to machine code because they contain code that cannot be translated to IL. Like _asm, note the C4793 warning you got for the first snippet. Suppress the warning with #pragma managed. Such code cannot use any managed types of course.

    The unit of code generation is a function. What cannot work is a function that needs both. Your main() function must be compiled to IL because it uses managed types. The function won’t be inlined of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would a C++ CLI compiler be able to compile some large sets of C++
Using C++/CLI, How to display a managed control (eg. System::Windows::Forms::Panel^) on a window created
I need to create a C++/CLI mixed assembly that can schedule future calls into
The language Forth offers a compile-time escape mechanism where code can be executed immediately,
everyone, I was trying to compile a program using C++/CLI to check my stocks,
I created a C++/CLI assembly that creates a wrapper around native C++ code. The
Does Mono .NET support and compile C++ / CLI? If not, do you know
In C++/CLI , you can use native types in a managed class by it
I have followed this thread now when i try to build using maven plugin
I am having problems creating a managed class with namespace in C++/CLI. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.