Search Results

Search found 5015 results on 201 pages for 'compiler construction'.

Page 40/201 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Safely defining variables for public callback functions in javascript

    - by djreed
    I am working with the YouTube iFrame API to embed a number of videos on a page. Documentation here: https://developers.google.com/youtube/iframe_api_reference#Requirements In summary, you load the API asynchronously using the following snippet: var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); Once loaded, the API fires the predefined callback function onYouTubePlayerAPIReady. For additional context: I am defining a library file for this in Google Closure. I am providing a namespace: goog.provide('yt.video'); I then use goog.exportSymbol so that the API can find the function. That all works fine. My challenge is that I would like to pass 2 variables to the callback function. Is there any way to do this without defining these 2 variables in the context of the window object? goog.provide('yt.video'); goog.require('goog.dom'); yt.video = function(videos, locales) { this.videos = videos; this.captionLocales = locales; this.init(); }; yt.video.prototype.init = function() { var tag = document.createElement('script'); tag.src = "http://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); }; /* * Callback function fired when YT API is ready * This is exported using goog.exportSymbol in another file and * is being fired by the API properly. */ yt.video.prototype.onPlayerReady = function(videos, locales) { window.console.log('this :' + this); //logs window window.console.log('this.videos : ' + this.videos); //logs undefined /* * Video settings from Django variable */ for(i=0; i<this.videos.length; i++) { var playerEvents = {}; var embedVars = {}; var el = this.videos[i].el; var playerVid = this.videos[i].vid; var playerWidth = this.videos[i].width; var playerHeight = this.videos[i].height; var captionLocales = this.videos[i].locales; if(this.videos[i].playerVars) var embedVars = this.videos[i].playerVars; } if(this.videos[i].events) { var playerEvents = this.videos[i].events; } /* * Show captions by default */ if(goog.array.indexOf(captionLocales, 'es') >= 0) { embedVars.cc_load_policy = 1; }; new YT.Player(el, { height: playerHeight, width: playerWidth, videoId: playerVid, events: playerEvents, playerVars: embedVars }); }; }; To intialize this, I am currently using the following within a self-executing anonymous function: var videos = [ {"vid": "video_id", "el": "player-1", "width": 640, "height": 390, "locales": ["es", "fr"], "events": {"onStateChange": stateChanged}}, {"vid": "video_id", "el": "player-2", "locales": ["es", "fr"], "width": 640, "height": 390} ]; var locales = ['es']; var videoTemplate = new yt.video(videos, locales);

    Read the article

  • The type or namespace name 'WebControls' could not be found (are you missing a using directive or an assembly reference?)

    - by user1467175
    I encountered this error: The type or namespace name 'WebControls' could not be found (are you missing a using directive or an assembly reference?) Source Error: Line 28: Login Login1 = (WebControls.Login)LoginView1.FindControl("Login1"); // here the error code Line 29: TextBox UserName = (TextBox)Login1.FindControl("UserName"); Line 30: TextBox FailureText = (TextBox)Login1.FindControl("FailureText"); I did some research and the solution was to add this into the source code: System.Web.UI.WebControls.Login but I have no idea where this code can be add into. At first I tried putting it as a namespace, but it was wrong. Anyone can tell me where should I place this code at?? EDIT protected void Login1_LoginError(object sender, System.EventArgs e) { //Login Login1 = (WebControls.Login).LoginView1.FindControl("Login1"); Login Login1 = (System.Web.UI.WebControls.Login)LoginView1.FindControl("Login1"); TextBox UserName = (TextBox)Login1.FindControl("UserName"); TextBox FailureText = (TextBox)Login1.FindControl("FailureText"); //There was a problem logging in the user //See if this user exists in the database MembershipUser userInfo = Membership.GetUser(UserName.Text); if (userInfo == null) { //The user entered an invalid username... FailureText.Text = "There is no user in the database with the username " + UserName.Text; } else { //See if the user is locked out or not approved if (!userInfo.IsApproved) { FailureText.Text = "When you created your account you were sent an email with steps to verify your account. You must follow these steps before you can log into the site."; } else if (userInfo.IsLockedOut) { FailureText.Text = "Your account has been locked out because of a maximum number of incorrect login attempts. You will NOT be able to login until you contact a site administrator and have your account unlocked."; } else { //The password was incorrect (don't show anything, the Login control already describes the problem) FailureText.Text = string.Empty; } } }

    Read the article

  • GCC compile time division error

    - by kartikmohta
    Can someone explain this behaviour? test.c: #include <stdio.h> int main(void) { printf("%d, %d\n", (int) (300.6000/0.05000), (int) (300.65000/0.05000)); printf("%f, %f\n", (300.6000/0.05000), (300.65000/0.05000)); return 0; } $ gcc test.c $ ./a.out 6012, 6012 6012.000000, 6013.000000 I checked the assembly code and it puts both the arguments of the first printf as 6012, so it seems to be a compile time bug.

    Read the article

  • Routing algorithm

    - by isaac
    Hello, I'm giving a presentation about computer routing and I want to make a good analogy with a real-world situation. However, I could not find it. Do you have in mind any of the situations like the computer routing. If yes, could you please provide me with it

    Read the article

  • error in c, but not in c++

    - by eswar
    const int t=5; char buf[t+5]; When I compile this gives error in C but not in C++!! Can anybody please explain me the reason? Note: I know the const defaults to internal linkage in 'C++', where as in 'C' it defaults to external linkage. Does it has any relation to the above case??

    Read the article

  • difference between C(gcc 4.3.2) , C 99 strict(gcc 4.3.2) , C++(gcc-4.0.0-8) ,C++(gcc-4.3.2)

    - by user1139048
    I have the following questions concerning the differences between the four options: What is the main difference between the four options? Which of the above support int64_t or long long without suffix LL. I want a data type of the range 2^63 - 1 If your answer to my second question is not C(gcc 4.3.2) , whether the code I write in C(gcc 4.3.2) for C language will be valid in rest of the three options or do I have to modify something, then what will be those modifications.

    Read the article

  • C++: Can't use std::wstringstream

    - by Rosarch
    For some reason, my project won't compile when I try to create a wstringstream: std::wstringstream stringstream; This causes error C2079: 'stringstream' uses undefined class 'std::basic_stringstream<_Elem, _Traits, _Alloc with [_Elem=wchar_t, _Traits=std::char_traits, _Alloc=std::allocator' What am I doing wrong?

    Read the article

  • Error compiling basic java code

    - by Michael Younani
    New to java. Practicing coding by following a book. Heres my code: class Motorcycle { //Three instance variables - make and color are strings. while a boolean refers to TRUE OR FLASE(in this case off or on) String make; String color; boolean engineState; void startEngine() { if (engineState == true) System.out.print("The engine is already on."); else { engineState = true; System.out.print("The engine is now on."); } void showAtts() { System.out.print("This motorcycle is a " + color + " " + make); if (engineState ==true) System.out.print("The engine is on."); else System.out.print("The engine is off."); } } } When I compile I get 2 errors: 1) illegal start of expression 2) ; expected I can't pin point the problem. If anyone can direct me or hint me please do.

    Read the article

  • regular expression for bit strings with even number of 1s

    - by equilibrium
    Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L? A) (0*10*1)* B) 0*(10*10*)* C) 0*(10*1)* 0* D) 0*1(10*1)* 10* According to me option D is never correct because it does not represent the bit string with zero 1s. But what about the other options? We are concerned about the number of 1s(even or not) not the number of zeros doesn't matter. Then which is the correct option and why?

    Read the article

  • Scala unsatisfiable cyclic dependency in "table-layout" library (Toolkit class)

    - by Atol
    When I try to compile with sbt some code containing an instance of a Table from this library I get this error: java.lang.AssertionError: assertion failed: unsatisfiable cyclic dependency in 'class Toolkit' It seems to work with Java so I don't understand why it fails in Scala. Here is the toolkit class: http://code.google.com/p/table-layout/source/browse/branches/v1/tablelayout/src/com/esotericsoftware/tablelayout/Toolkit.java As long as I get this error I'm totally stopped in my project :(.

    Read the article

  • Using PHP's exec() function (or the likes), how can you display terminal error output?

    - by Miciah Amberong
    Previous Reference I am just wondering if there's a way (using PHP) to output the compile error information from the terminal to the browser? For example: If you use this code to execute in the terminal... gcc -o try try.c ...and assuming the "try.c" have some errors. The terminal will output something like this: try.c In function 'main': try.c:27 'x' undeclared (first use in this function) try.c:27 (Each undeclared identifier is reported only once try.c:27 for each function it appears in.) Meanwhile, using this PHP code... <?php exec("gcc -o try try.c"); ?> The browser does not return any output like the terminal does. Is there a possible way direct or indirect that the error details that the terminal showed can be passed to the be displayed on a browser? Thank you very much.

    Read the article

  • passing arg2 of 'listFind' from incompatible pointer type

    - by lego69
    Hello, I've got some problem with my function and don't know how to solve this problem, This is my code: ListResult result=listFind(currentLines, compareBasicLines, &linePrototype); <-here problem compareBasicLines pointer to function int compareBasicLines(ptrLine line1, ptrLine line2){ COMPARE_NUMBER_STRINGS(line1, line2); } COMPARE_NUMBER_STRINGS(line1, line2); defined in another file #define COMPARE_NUMBER_STRINGS(var1, var2) \ if(var1 == NULL || var2 == NULL){ \ return 0; \ } \ return strcmp(var1->strNumber, var2->strNumber); thanks in advance for everyone

    Read the article

  • Strange compilation error on reference passing argument to function

    - by Grewdrewgoo Goobergabbsoen
    Here's the code: #include <iostream> using namespace std; void mysize(int &size, int size2); int main() { int *p; int val; p = &val; cout << p; mysize(&val, 20); // Error is pointed here! } void mysize(int &size, int size2) { cout << sizeof(size); size2 = size2 + 6000; cout << size2; } Here's the error output from GCC: In function 'int main()': Line 10: error: invalid initialization of non-const reference of type 'int&' from a temporary of type 'int*' compilation terminated due to -Wfatal-errors. What does that imply? I do not understand the error message ... invalid initialization of a non-constant? I declared the prototype function above with two parameters to take, one a reference of an integer and one just an integer value itself. I passed the reference of the int (see line 10), yet this error keeps being thrown at me. What is the issue?

    Read the article

  • expected identifier or '(' before '{' token in Flex

    - by user1829177
    I am trying to use Flex to parse 'C' source code. Unfortunately I am getting the error "expected identifier or '(' before '{' token" on lines 1,12,13,14... . Any ideas why? %{ %} digit [0-9] letter [a-zA-Z] number (digit)+ id (letter|_)(letter|digit|_)* integer (int) character (char) comma [,] %% {integer} {return INT;} {character} {return CHAR;} {number} {return NUM;} {id} {return IDENTIFIER;} {comma} {return ',';} [-+*/] {return *yytext;} . {} %% main() { yylex(); } The corresponding flex file is as shown below: %{ #include <ctype.h> #include <stdio.h> #include "myhead.h" #include "mini.l" #define YYSTYPE double # undef fprintf %} %token INT %token CHAR %token IDENTIFIER %token NUM %token ',' %left '+' '-' %left '*' '/' %right UMINUS %% lines:lines expr '\n' {printf("%g\n",$2);} |lines '\n' |D | ; expr :expr '*' expr {$$=$1*$3;} |expr '/' expr {$$=$1/$3;} |expr '+' expr {$$=$1+$3;} |expr '-' expr {$$=$1+$3;} |'(' expr ')' {$$=$2;} |'-' expr %prec UMINUS {$$=-$2;} |IDENTIFIER {} |NUM {} ; T :INT {} |CHAR {} ; L :L ',' IDENTIFIER {} |IDENTIFIER {} ; D :T L {printf("T is %g, L is %g",$1,$2);} ; %% /*void yyerror (char *s) { fprintf (stderr, "%s\n", s); } */ I am compiling the generated code using the command: gcc my_file.c -ly

    Read the article

  • How do I remove the alert: "...may not respond to..."

    - by balexandre
    In my .m file I call a method that is inside the same .m file. In the header I have the correct import for the header but I keep getting this alert: What am I doing wrong? What should I do in order to make this error disappear? I'm kinda lost here :-( Even if I changed this to: NSString *path = [[NSString alloc] initWithString:@"...."]; [self parseXMLFileAtURL:path]; [path release];

    Read the article

  • Function defined but not used in C

    - by thetna
    I have following code: static __inline__ LIST list_List(POINTER P) { return list_Cons(P,list_Nil()); } After compilation I got following warning: inlining is unlikely but function size may grow I removed the inline and changed into the following : static LIST list_List(POINTER P) { return list_Cons(P,list_Nil()); } Now I get the following warning: list_List is defined but not used. Can anybody please suggest me how can remove that warning.

    Read the article

  • Can code formatting lead to change in object file content?

    - by kumar
    I have run though a code formatting tool to my c++ files. It is supposed to make only formatting changes. Now when I built my code, I see that size of object file for some source files have changed. Since my files are very big and tool has changed almost every line, I dont know whether it has done something disastrous. Now i am worried to check in this code to repo as it might lead to runtime error due to formatting tool. My question is , will the size of object file be changed , if code formatting is changed.?

    Read the article

  • C++ STL: Trouble with iterators

    - by Rosarch
    I'm having a beginner problem: bool _isPalindrome(const string& str) { return _isPalindrome(str.begin(), str.end()); // won't compile } bool _isPalindrome(string::iterator begin, string::iterator end) { return begin == end || *begin == *end && _isPalindrome(++begin, --end); } What am I doing wrong here? Why doesn't str.begin() get type checked to be a string::iterator?

    Read the article

  • Deprecated functions not spotted if using "System::Threading::ThreadState" (and others!) C++ VS2005/

    - by Fishboy
    Hi, I'm facing an issue with c++ on vs2005 and also vs2008... here's how you can reproduce the issue.... create a new (c++) project called 'test' (file|new|project) select "Windows Forms Application" and add the 'stdio.h' include and the code fragment below into the test.cpp source file..... -------------------start of snippet-------------------- #include <stdio.h> ... int main(array<System::String ^> ^args) { int i; System::Threading::ThreadState state; char str[20]; sprintf (str, "%s", "test string"); ... -------------------end of snippet-------------------- If you compile the code as above (you'll have to 'buildall' first), you'll get two warnings about 'i' and 'state' being unreferenced (nothing about sprintf being deprecated). If you comment out "System::Threading :Thread state;", you'll get one warning about 'i' being unreferenced and another warning (C4996) for the 'deprecated' sprintf statement.... This issue also occurs for "System::Windows::Forms::MessageBoxIcon", "System::Base64FormattingOptions" (and perhap all 'enum class' types!) Anyone know of the cause and workaround to the issue demonstrated here ( i have other files that demonstate this issue..). (I had started a thread on msdn, but then found this site! see link below) Visual Studio 2005 has stopped warning about deprecated functions

    Read the article

  • Error in value of default parameter [Bug in Visual C++ 2008?]

    - by HellBoy
    I am facing following issue while trying to use template in my code I have some C++ code which i call from C functions. Problem is I am getting different values in the following code for statement 1 and 2. Type id : unsigned int statement 1 : 4 statement 2 : 1 C++ Code : template <typename T> void func(T* value, unsigned int len = sizeof(T)) { cout << "Type id : " << typeid(T).name() << endl; cout << "statement 1 " << sizeof(T) << endl; cout << "statement 2 " << len << endl; } template <typename T> void func1(T data) { T val = data; func(&val); } C Code : void test(void *ptr, unsigned int len) { switch(len) { case 1: func1(*(static_cast<uint32_t *>(ptr)) break; } } This happens only on windows. On Linux it works fine.

    Read the article

  • Why call-by-value evaluation strategy is not Turing complete?

    - by Roman
    I'm reading an article about different evaluation strategies (I linked article in wiki, but I'm reading another one not in English). And it says that unlike to call-by-name and call-by-need strategies, call-by-value strategy is not Turing complete. Can anybody explain, please, why is it so? If it's possible, add an example pls.

    Read the article

  • VS2010 (older) installer project - two or more objects have the same target location.

    - by Hamish Grubijan
    This installer project was created back in 2004 and upgraded ever since. There are two offending dll files, which produce a total of 4 errors. I have searched online for this warning message and did not find a permanent fix (I did manage to make it go away once until I have done something like a clean, or built in Release, and then in Debug). I also tried cleaning, and then refreshing the dependencies. The duplicated entries are still in there. I also did not find a good explanation for what this error means. Additional warnings are of this nature: Warning 36 The version of the .NET Framework launch condition '.NET Framework 4' does not match the selected .NET Framework bootstrapper package. Update the .NET Framework launch condition to match the version of the .NET Framework selected in the Prerequisites Dialog Box. So, where is this prerequisites box? I want to make both things agree on .Net 4.0, just having a hard time locating both of them.

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >