Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to run a what I called "script C code" from string in my C++ program, for exemple :
int main(){
// my string (from a file): printf("Hello, Stackoverflow!")
RunScript(MyStringScript);
return 0;
}
I could use clang or other, but I have no idea how to do that...
PS: The goal is not to make a C interpreter, no, just run a C code to broaden my program.
The best way for reaching your goal, is to use a C interpreter library.
For example you can use this one: https://github.com/jpoirier/picoc
You could also do it with libjit. Because you are then running the system compiler, any ISO C/C++ code can be compiled (picoc is not fully ISO C complete)
Obligatory disclaimer: Running user supplied code at runtime is very dangerous unless it is properly sandboxed. Maybe consider doing it another way.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a bit new to programming and I just wanted to know if there can be any problems if I send my C++ code I wrote on Eclipse to a friend who works on VC++?
Yes, there can be problems.
Whether the code can simply be copy/pasted to another toolchain entirely depends on how standard-compliant and portable the code is.
We cannot guess at that from here.
There should be no problem as long as you are not using any compiler-specific things, which is unlikely if you are a beginner.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Im writing a code in c++ with codeblocks. I included the flag : " get g++ follow c++ 11.." In the compiler settings to use chrono class, but after i included this flag i couldent compile the program because suddenly the function fopen64 "was not declared in the scope". Just so you know- i can compile the program without the flag.
How can i use both fopen64 and chrono class? Is this possible? And if not, is there other precise time measurement class so i can use to mesure microseconds?
Thanks!
The fopen64() function is from the Linux Large File Support library. It’s just a version of fopen() that supports files larger than 2Gbi. On a modern system, you can use the standard library function, fopen(). On Posix, you can use fseeko() and ftello() and on Windows, _fseeki64() and _ftelli64(). That said, defining _LARGEFILE_SOURCE might work on your compiler.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Let's say we've got a first program called Program1.exe which contains the necessary information to create and compile another application called Program2.exe. Actually it could also load that information from a txt file or whatever.
Googling, I've found that this is "easy" to do in C#, using Visual Studio:
How to programatically build and compile another c# project from the current project
Programmatically Invoke the C# Compiler
The problem is that I'm not using (and can't use) C#, but C++. Summing it up, my question is if that I can do this same thing using C++.
I would prefer to do it without additional libraries, but if that's not possible, or if it's too hard to do, you can also recommend any library allowing it.
I think you'll probably have noticed it, but my goal is to use it under Windows so I don't care if it's not portable.
Thanks everybody.
It's trivial (if maybe a bit odd) for a C++ program to compile and run another based on code stored in a text file. Debugging that other program, however, isn't.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to put C/C++ code into Objective C programs.
What's the exact way to do that ?
I've tried many times.
So, if someone know how to that, please explain the way from zero (from a empty project) and give me some class examples ;)
(i work on Xcode 5.0.2)
Thank you !
Using XCode, rename the file extension of the files with C++ code from .m to .mm for C++.
Objective C is a superset of C, so pure C code will compile without any required changes.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm planning on suggesting to my development team that we start looking at lua instead of C++ for the project we're currently working on. On that subject I have a question that I need to clear up first.
With the current SDK, we are not allowed to use C++ exceptions due to it not being safe in multithreaded applications (created with that SDK). Actually, it is allowed, just discouraged... however the program won't compile unless we pass -fno-exceptions, so... yeah...
Anyway. Since Lua runs in it's own VM and is pure C... Would exceptions in Lua be 'safe'?
If the C code that makes up the LUA interpreter is fine concerning the restrictions of your SDK then anything coded in LUA and executed with that interpreter is fine, too. But if the LUA interpreter itself is working with your unnamed SDK... that's a question that only you or the SDK vendor can answer.