How to choose between interpreter and compiler?

How to choose between interpreter and compiler? – Software Engineering Stack Exchange

unity – Compiler error “Name “assetImporter” not available”

I want to split all the animations inside a FBX by using a .txt file which contains start times and names for the animations in this FBX.

I found a script that does exactely that here.

However, this script uses the PostProcessor, and this means that I have little possiblity over when it’s called.

Instead, I would like this to happen when I click a certain menu item.
To do that, I have added a new menu item to the Unity toolbar like this:

public class NewBehaviourScript : MonoBehaviour
{
    (MenuItem("Tools/FBX/Split"))
    private static void SplitFBX()
    {

However, as soon as I add the line

 ModelImporter modelImporter = assetImporter as ModelImporter;

from the other script, the Editor says that

 "The name assetImporter isn't available in the current context".

Does anybody see why this compiler error occurs?

This is the entire script:

using UnityEngine;
using UnityEditor;
using UnityEditor.VersionControl;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;
using System;

public class NewBehaviourScript : MonoBehaviour
{
    (MenuItem("Tools/FBX/Split"))
    private static void SplitFBX()
    {
        var selected = Selection.activeObject;
        string assetPath = AssetDatabase.GetAssetPath(selected);

        EditorUtility.DisplayDialog("", assetPath, "Ok");

        try
        {
            // Remove 6 chars because dataPath and assetPath both contain "assets" directory
            string fileAnim = Application.dataPath + Path.ChangeExtension(assetPath, ".txt").Substring(6);

            if (!File.Exists(fileAnim))
            {
                return;
            }

            StreamReader file = new StreamReader(fileAnim);

            string sAnimList = file.ReadToEnd();
            file.Close();

            if (EditorUtility.DisplayDialog("FBX Animation Import from file", fileAnim, "Import", "Cancel"))
            {
                System.Collections.ArrayList List = new ArrayList();
                pParseAnimFile(sAnimList, ref List);

                ModelImporter modelImporter = assetImporter as ModelImporter;
                modelImporter.clipAnimations = (ModelImporterClipAnimation())List.ToArray(typeof(ModelImporterClipAnimation));

                EditorUtility.DisplayDialog("Imported animations", "Number of imported clips: " + modelImporter.clipAnimations.GetLength(0).ToString(), "OK");
            }
        }
        catch (Exception e)
        {
            // EditorUtility.DisplayDialog("Imported animations error: ", e.Message, "OK");
        }
    }

    void pParseAnimFile(string sAnimList, ref System.Collections.ArrayList List)
    {
        Regex regexString = new Regex(" *(?<firstFrame>(0-9)+) *- *(?<lastFrame>(0-9)+) *(?<loop>(loop|noloop| )) *(?<name>(^r^n)*(^r^n^ ))",
                                      RegexOptions.Compiled | RegexOptions.ExplicitCapture);

        Match match = regexString.Match(sAnimList, 0);
        while (match.Success)
        {
            ModelImporterClipAnimation clip = new ModelImporterClipAnimation();

            if (match.Groups("firstFrame").Success)
            {
                clip.firstFrame = System.Convert.ToInt32(match.Groups("firstFrame").Value, 10);
            }
            if (match.Groups("lastFrame").Success)
            {
                clip.lastFrame = System.Convert.ToInt32(match.Groups("lastFrame").Value, 10);
            }
            if (match.Groups("loop").Success)
            {
                clip.loop = match.Groups("loop").Value == "loop";
            }
            if (match.Groups("name").Success)
            {
                clip.name = match.Groups("name").Value;
            }

            List.Add(clip);

            match = regexString.Match(sAnimList, match.Index + match.Length);
        }
    }
}

compiler – How Do Codes Work Without Getting Compiled or Interpreted

Compilers aren’t magic – they’re just programs, which can be run from the command line. VSCode has a “Terminal” tab in the bottom pane of the default UI, where you can invoke the compiler. (For non-trivial applications, you probably wouldn’t be running the compiler directly, but would instead be running some software that also handles linking and other stuff; in a linux-style environment that might be make, or ant for java.)

But re-typing the compiler invocation gets old pretty quickly, so VSCode has some shortcuts available. In the “Terminal” menu there are entries for “Run Task” and “Run Build Task” – if you select one of these, VSCode will present you with any auto-detected tasks it can come up with from what your project looks like.

Global vs local CMake functions for compiler flags

Do not use global functions: This includes link_directories, include_libraries, and similar.

Yet the only 2 use cases I’ve seen of CMake in are:

  • make a couple of libraries and a binary using them OR
  • compile a simple binary
  • (fetching external dependencies; testing; file generation – not relevant)

In the first case identical compiler and linker flags are strongly encouraged to ensure binary compatibility. In the second case it doesn’t matter.

Then, is the following wrong? If not, in what contexts(use cases) would it be considered wrong, as stated by the quote at the very beginning of the question?

add_compile_options( -Wall -Wextra -pedantic -Werror -Wfatal-errors ${OpenMP_CXX_FLAGS} 

coding theory – Using C++ programming language and the required compiler and word editor

coding theory – Using C++ programming language and the required compiler and word editor – Computer Science Stack Exchange

parsing – Advice on writing S-Expression to JSON compiler that allow to extend the parser

I’m search for solution for the problem I have dumb simple Scheme to JSON compiler (in my Scheme in JavaScript interpreter). It just written my list structures (S-Expression) into JSON, the file is little bit bigger but using JavaScript built-in parser, it’s way much faster to load standard library that is written in Scheme.

My simple JSON compiler works fine, the problem is that in my interpreter I’m allowing to extend the parser, example is this simple code:

(set-special! "<>" 'x)

(define (x arg)
  `(vector ,arg))

(print <>10)

The evaluation work together with the parser each S-Expression is parsed then evaluated then next expression is parsed.

when evaluating it, it prints #(10) which is Scheme vector and in JavaScript it’s just Array.

The problem is that this happen while evaluating the code, set-special! change the parser and add new token <> that add hook to the parser that return vector.

When I’m compiling the code to JSON, I’m just parsing the code and not evaluating it, so function x is not known and new syntax is also not known, I would need to execute the code to know them since they are runtime.

And when I’m evaluating compiled JSON I’ve got exactly same code not (print #(10)), so it’s just normal symbol in the middle of the print. Also because this syntax is invoked by the parser, that is not invoked when evaluating the code, so I got error that symbol <> is not defined, in Scheme <> is normal identifier that can be variable, function or macro.

My question is how would you handle this case? What advice can you give me?

One note is that I don’t have proper expansion time for macros yet and all macros are executed at runtime, they are like functions that return code that is evaluated. When the code was only interpreted this didn’t matter much.

Will making this work require to write proper expansion time. I’m not sure how Common Lisp do this, since it have similar concept of compiler and reader macros that work like my syntax extensions.

android – My compiler gets stopped because of library linking order in SDL2

I’ve been trying to compile my C++ SDL2 program that uses SDL , SDL_Image ,SDL_mixer , SDL_ttf and in my compiler (Compiler : Cxxdroid ; OS : Android) , to compile them , I need to link all libraries by myself . In case of vorbisenc, vorbis and vorbisfile , I was trying to do the following method

-lm -ldl -llog -lz -landroid -lGLESv1_CM -lGLESv2 -lGLESv3  -lSDL2 -lSDL2_image -lSDL2_test  -lSDL2_mixer -lSDL2_ttf -lSDL2main -ljpeg -lpng -lpng16 -ltiff -ltiffxx -lfreetype -lwebp -lwebpdemux -logg -lvorbisfile -lvorbisenc -lvorbis -lFLAC++ -lFLAC -lmodplug -lmpg123 -lout123

Then the compiler said that undefined reference to “Every OGG function” . So I linked the library ogg next after vorbis .

-lm -ldl -llog -lz -landroid -lGLESv1_CM -lGLESv2 -lGLESv3  -lSDL2 -lSDL2_image -lSDL2_test  -lSDL2_mixer -lSDL2_ttf -lSDL2main -ljpeg -lpng -lpng16 -ltiff -ltiffxx -lfreetype -lwebp -lwebpdemux -lvorbisfile -lvorbisenc -lvorbis -logg -lFLAC++ -lFLAC -lmodplug -lmpg123 -lout123

That solved the problem . But after compiling , my compiler doesn’t run the program and crushes . Is something wrong in my order of linking ?

Note , in order to compile, I need to link libandroid.so since my OS is android

compile – A problem with C compiler

I have Mathematica 12.1 installed on Windows 10, and would like to compile functions using C compiler. I have installed Visual Studio Express 2017.

In Mathematica, when running

Needs("CCompilerDriver`")
CCompilers()
DefaultCCompiler()

I get

{{“Name” -> “Visual Studio”, “Compiler” ->
CCompilerDriverVisualStudioCompilerVisualStudioCompiler,
“CompilerInstallation” -> “C:Program Files (x86)Microsoft
Visual Studio2017WDExpress”, “CompilerName” -> Automatic}}

CCompilerDriverVisualStudioCompilerVisualStudioCompiler

When running some example, however, I get

Compiler`$CCompilerOptions = {"ShellCommandFunction" -> Print, "ShellOutputFunction"->Print};
cGen = Compile({{x}}, x^2 + Sin(x^2), CompilationTarget -> "C")

C:UsersuserAppDataRoamingMathematicaApplicationDataC
CompilerDriverBuildFolderlaptop-u485fl4q-19944Working-laptop-
u485fl4q-19944-10492-14>call “C:Program Files (x86)Microsoft Visual
Studio2017WDExpressVCAuxiliaryBuildvcvarsall.bat” amd64
**********************************************************************

** Visual Studio 2017 Developer Command Prompt v15.9.34
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

(vcvarsall.bat) Environment initialized for: ‘x64’ ‘cl.exe’ is not
recognized as an internal or external command, operable program or
batch file.

Compile::nogen: A library could not be generated from the compiled
function.

Could you please tell me what may be a reason for this?

How the property of convergence or divergence of a mathematical function is used in the design of body of a program in a compiler like C

A function in C returns a value how this aspect of C Programming is concern with convergence and divergence of a function in maths.

c++ – Compiler error mingw32-make.exe: *** [Arrays.mk:97: ../build-Debug/Section7/main.cpp.o] Error 1

Can you help me?

I was writing my code :

#include
using namespace std;

int main() {

char vowels() = {'a' ,'e', 'i', 'o', 'u' };
cout << "nThe first vowel is: " << vowels(0) << endl;
cout << "The last vowel is: " << vowels(4) << endl;

return 0;

}

and it’s show :

C:WINDOWSsystem32cmd.exe /C “”C:/Program Files/mingw-w64/mingw64/bin/mingw32-make.exe” -j2 SHELL=cmd.exe -e -f “Arrays.mk” MakeIntermediateDirs && “C:/Program Files/mingw-w64/mingw64/bin/mingw32-make.exe” -j2 SHELL=cmd.exe -e -f “Arrays.mk” ../build-Debug/Section7/main.cpp.o”
———-Building project:( Arrays – Debug ) (Single File Build)———-
“C:/Program Files/mingw-w64/mingw64/bin/g++.exe” -c “C:/Users/(Username)/Documents/CPP Course/Section7/Section7/Section7/main.cpp” -g -O0 -std=c++17 -Wall -o /Users/(Username)/Documents/CPP Course/Section7/Section7″/build-Debug//Users/(Username)/Documents/CPP Course/Section7/Section7/Section7/main.cpp.o -I. -I.
g++.exe: error: Course/Section7/Section7/build-Debug//Users/(Username)/Documents/CPP Course/Section7/Section7/Section7/main.cpp.o -I. -I. : No such file or directory
mingw32-make.exe: *** (Arrays.mk:97: ../build-Debug/Section7/main.cpp.o) Error 1
====0 errors, 0 warnings====

and the code (cmd) just opened and just closed it

can you help?

enter image description here

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123