mfc >> including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 17 Mar 2006 01:38:10 GMT

The MFC application that I am working on generates a C code. My next
task is to include a C compiler in the application which can compile
the code being generated and also indicate any errors in the code to
the user.

I am using Visual Studio .net to develop the application.Which compiler
shd I use and how will I be able to include it in the system? I tried
using GCC but dint find a gd documentation on how to include it in VS
.Net.

Does anyone have any suggestions? Thanks



mfc >> including C compiler in MFC on Visual Studio .Net

by Ajay Kalra » Fri, 17 Mar 2006 01:47:23 GMT








Any of the Visual C++ compilers will compile C code as well. You dont need
any external compiler. What exactly is the problem that you are facing?





mfc >> including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 17 Mar 2006 01:51:04 GMT

The problem is that I am new to this stuff...so I dont know know how to
go abt it.



including C compiler in MFC on Visual Studio .Net

by Ajay Kalra » Fri, 17 Mar 2006 01:55:27 GMT

There is nothing really special about it. Include the .c file in the project
just like you would include a .cpp file. Right click on the file in
solution explorer/Workspace and in its properties, ask it not to use
precompiled header files.








including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 17 Mar 2006 02:09:16 GMT

Thanks a lot Ajay.

But i dont understand one thing i.e. The C code is being generated in
run time, so how will I command the code to be compiled in run time?
and how will I retrieve the errors indicated by the compiler in the
code .



including C compiler in MFC on Visual Studio .Net

by Tom Serface » Fri, 17 Mar 2006 02:22:19 GMT

The user will have to have a C compiler as well to run your C based scripts.
If the C code is simple you could include something like:

http://fabrice.bellard.free.fr/tcc/

You could start this with ShellExecuteEx()...

A lot depends on what you want to do with the compiled code... If you are
trying to include a scripting language you may want to consider something
like:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp

Tom







including C compiler in MFC on Visual Studio .Net

by AliR » Fri, 17 Mar 2006 03:30:36 GMT

You cannot include the compiler in your application. If the user has a
compiler installed on their system then you can simply use that by using
it's commandline compiler. Like Ajay suggested. But there is no way to
compile or include a compiler in your application, unless you write the
compiler.

AliR.







including C compiler in MFC on Visual Studio .Net

by AliR » Fri, 17 Mar 2006 03:47:53 GMT

Actually you can download the GCC compiler's source code, you might be able
to turn that into a dll, and include that in your application.


AliR.









including C compiler in MFC on Visual Studio .Net

by Ajay Kalra » Fri, 17 Mar 2006 03:53:13 GMT

>the C code is being generated in run time

Sorry, I missed this. This can be done as Ali suggested. However, why are
you doing this? What if compiled code generates errors/warnings etc?
Perhaps you should look into scripting for your appliation.






including C compiler in MFC on Visual Studio .Net

by Vipin [MVP] » Fri, 17 Mar 2006 04:03:26 GMT

How is the C-code getting generated? Is it getting generated by a midl
compiler?

--
Vipin Aravind
http://www.explorewindows.com








including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 17 Mar 2006 09:53:28 GMT

The user writes chunks of codes of C , which are combined to generate
the whole code. The next step is to allow the user to see whether the
code generated is compilable or not. It shd also indicate whether thr
are any errors in the code so that the user can then make changes to it.



including C compiler in MFC on Visual Studio .Net

by Ajay Kalra » Fri, 17 Mar 2006 10:15:50 GMT

I am not sure how far you are going with this. If you dont own the
compiler, you would be looking for ways to communicate with it for
errors and warnings etc. You will need to be familiar with the compiler
communicating back to you. This is much more easier in .Net as it
allows compiling/deploying at run time.

------
Ajay Kalra
XXXX@XXXXX.COM



including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 17 Mar 2006 14:05:38 GMT

>The user will have to have a C compiler as well to run your C based scripts.

ShellExecuteEx needs an executable file. how can I get the exe file for
tcc? The file that i downloaded frm this site does not have any. And I
am also confused as to how shd I install tcc on windows.



including C compiler in MFC on Visual Studio .Net

by Tom Serface » Sat, 18 Mar 2006 00:49:25 GMT

You can create an executable from their code. Here is a site that has some
other information about free C compilers:

http://www.thefreecountry.com/compilers/cpp.shtml

If you're just looking to see if it compiles or not you might want to use
the Express version of Visual C++ which, I think, will still do C code.

Tom







including C compiler in MFC on Visual Studio .Net

by Riya » Fri, 24 Mar 2006 02:09:27 GMT

"This is much more easier in .Net as it allows compiling/deploying at
run time. "

How is this implementation possible? Is it done by using
CodeDomProvider and Process Class? I tried using this method as
suggested in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemCodeDomCompilerCodeDomProviderClassTopic.asp
but then I get stuck with errors associated with mscorlib and /clr
saying "managed targeted code requires a '/clr' option " which just
seems impossible to solve. I tried all solns given on the forum...but
nothing worked

Is there some other way to use the .Net VisualC compiler at runtime??



Similar Threads

1. VISUAL STUDIO .NET ENT ARCHITECT EDITION [5 CDs], VISUAL STUDIO NET PROFESSIONAL 2003 DVD, Addons, Tutorials

2. Visual Studio NET Enterprise Architect 2002 and Visual Studio NET 2003

very hard is fix exactly group for this question.. but I am sure that some 
of people here have some experience with these compilers: Visual Studio NET
Enterprise Architect 2002 and Visual Studio NET 2003

1. What is difference between Visual Studio NET Enterprise Architect 2002
and Visual Studio NET 2003

2. If I try user Visual Studio NET 2003, what I have not included inside (in
compare with Visual Studio NET 2003)?

3. Why Visual Studio NET 2003 is created?

4. Have Microsoft some newer versions of Visual Studio NET?





3. Visual Studio NET Enterprise Architect 2002 and Visual Studio NET 2003 difference

4. Visual C++6, MFC project to Visual Studio 2005 MFC

Hello,

I convert a Visual C++6, MFC  project to Visual Studio 2005 MFC and
I have a lot of warnings.

What I want?
  I want to sitch off the warnings and I make following without good
result.
  How is the correct way to do this?

 File: stdafx.h

#if !
defined(AFX_STDAFX_H__63C457B5_7B4F_11D5_A777_0001021D6D89__INCLUDED_)
#define AFX_STDAFX_H__63C457B5_7B4F_11D5_A777_0001021D6D89__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#define _CRT_SECURE_NO_DEPRECATE 1


#ifdef _MSC_VER_VS2005
#  pragma warning(disable:4927)
#  pragma warning(disable:4244)
#  pragma warning(disable:4018)
#  pragma warning(disable:4311)
#  pragma warning(disable:4312)
#endif


Second question:
 m_ListCtrl.SetItemData( nZeile, (DWORD) pArtikelposition );
 warning C4311: 'Type': Pointer 'CArtikelposition
*' to 'DWORD'

How can I do it correct?


Regards Andrea


5. Visual C++6, MFC project to Visual Studio 2005 MFC

6. Visual Studio .NET 2003\Vc7\include\vector(621) : error C244 confusion

Hello,

I am getting the following error using .NET 2003 and I wonder if
anyone can help me understand what is going on.

godcDoc.cpp(228) : warning C4267: '=' : conversion from 'size_t' to
'int', possible loss of data

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(621) : error C2440: 'initializing' : cannot
convert from 'std::vector<_Ty>::iterator' to
'std::vector<_Ty>::size_type'

        with
        [
            _Ty=Network *
        ]
        and
        [
            _Ty=Network *
        ]

        No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called

        C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(620) : while compiling class-template member
function 'std::vector<_Ty>::iterator
std::vector<_Ty>::insert(std::vector<_Ty>::iterator,const _Ty & )'
        with
        [
            _Ty=Network *
        ]

        godcDoc.cpp(136) : see reference to class template
instantiation 'std::vector<_Ty>' being compiled
        with
        [
            _Ty=Network *
        ]

It seems to be happening when the following lines are commented in.

std::vector<Network *> both;

both.push_back(&m_iNetwork);

Network is quite a complicated class that contains a lot of pointers
to things but all the #includes / forward declararions are in place.

Any help VERY much appreciated.