|
It is only the VS tool Intellisense that produces the red lines. Intellisense is not as clever as the compiler, so it may have trouble identifying some symbols. This is less of an issue in newer versions of VS (you didn't say which version you have), but it can still happen in code that requires multiple passes to interpret, e. g. code involving #define macros and/or templates.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I am using VS Ultimate 2013.
Stefan_Lang wrote: but it can still happen in code that requires multiple passes to interpret
Did you mean compile ? If not, what do you mean by multiple passes to interpret ??
This world is going to explode due to international politics, SOON.
|
|
|
|
|
I meant interpret in the sense to figure out what a line of code means. Maybe analyze is a better term. Both the compiler and Intellisense need to do this, although for the compiler that's just an intermediate step.
E. g. in a first pass, all preprocessor commands are interpreted, such as #include, #define, and #pragma. After that, most of the code should be plain C/C++, except template definitions: template code is not complete until you specify the template arguments, and that may only happen much later in the code, or, possibly, not at all in the current compilation unit. The purpose of Intellisense (or one of its purposes) is to give you instant feedback on the correctness of code as you type. But it can't give you that feedback for code that requires other code from an entirely different part of the solution.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
The underlining is done by the editor which is part of the IDE. It parses the source files and tries to find the definitions of variables, functions etc., in the source file itself and the included files. Stefan called this process "interpretation".
The parser (the part of the IDE that does this job) is not a compiler. But it is somewhat similar to a compiler by performing identical or similar tasks to check the source code.
A compiler processes his input files not in one go but uses multiple "passes". The parser might not do this or might not perform always similar to a compiler. This may then lead to the behaviour you are seeing.
|
|
|
|
|
It dependes on the identifier, where in the code it occurs, and what results you get from the build. Without more information it's difficult to make any other comments.
|
|
|
|
|
I am building a small database app on SAM3x8e hardware and decided that C++ will do.
I basically need to find a matching record and have an idea how to do it.
I don't see any timing issues.
I was just curious how the "big boys" do search on VERY large database.
I have heard about hash tables etc.
OK, I can Goggle , but some pointers would be appreciated.
Cheers
Vaclav
|
|
|
|
|
I'm unclear on what you are asking. Are you using an existing database product? Or are you trying to create your own database system?
|
|
|
|
|
It is almost impossible to search a database without an SQL like query language, unless you know the exact structure of the data held inside it.
|
|
|
|
|
Vaclav_Sal wrote: I am building a small database app on SAM3x8e hardware...I was just curious how the "big boys" do search on VERY large database.
First part of that is basically incompatible with the second.
In general the solution for your problem is similar in a very broad way in that one must:
1. Understand the data
2. Understand the searches needed.
The solution(s) are then based on that.
So for example it is pointless to use a hash if you are doing regular expression searches on free form text.
|
|
|
|
|
Hello there, Im trying to make an assembly program that translates a simple switch case program in c without using and commands related to jg or jt only jmp
I tried making something like this:
org 100h
mov si,3
jmp word ptr [jmptab+si]
case1:
PRINTN "Number One"
jmp endcases
case2:
PRINTN "Number Two"
jmp endcases
case3:
PRINTN "Number Three"
jmp endcases
case4:
PRINTN "Number Four"
endcases:
jmptab:
DW case1
DW case2
DW case3
DW case4
mov ah, 0
int 16h
ret
include magshimim.inc
Where did I go wrong?
modified 11-Jul-15 8:53am.
|
|
|
|
|
[This should really go in QA]
Hint:
a. What is the size of each entry in your jump table?
b. How are you indexing the jump table?
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Completely new to C++ and have been given a task that includes creating an application that uses CString data from a completely separate .h file.
The CStrings consist of info that I need to be able to copy to the clipboard, then be able to paste that text into word etc. I have set up a button in the application so when that button is pressed it executes what I want it to do (read the CString data and copy it to the clipboard).
For a person of my skill level this is difficult and my colleagues do not have the time to support me on this learning project so I thought I could get some advice and pointers here. Any help would be greatly appreciated. I am an apprentice working in software for 2 months.
Kind regards,
Luke
|
|
|
|
|
Member 11822807 wrote: I have set up a button in the application so when that button is pressed it executes what I want it to do (read the CString data and copy it to the clipboard). This is what it does or this is what you want it to do?
Member 11822807 wrote: ...so I thought I could get some advice and pointers here. Any help would be greatly appreciated. So what EXACTLY do you have a question about?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
You have not actually told us what help you want, so I am guessing you want to know how to:
|
|
|
|
|
Hello guys. I am trying to make a simple TSP using Julmar TSP SDK. I am able to make a skeleton TSP which gets detected by Windows and its added line can be seen from Phone.exe.
I want to add a thread in this TSP, which generates fake call to Phone.exe
How do I take it further? Should I add a main()and instantiating all the classes in it, in my .tsp project? Or will I be doing something in TSPUI project (so that I setup few things during manual installation of TSP)? Thanks for giving any pointer.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Hello all!
I need help. I need to estimate function execution time in under Linux OS. I guess that it's right way to estimate code/algorithm performance.
I'm trying, something like this:
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
void test(){
int i;int s=0;
for(i=1; i<1000000; i++){s+=sin(i)/i;}
}
float timedifference_msec(struct timeval t0, struct timeval t1)
{
return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f;
}
int main(void)
{
struct timeval t0;
struct timeval t1;
float elapsed;
gettimeofday(&t0, 0);
f1();
gettimeofday(&t1, 0);
elapsed = timedifference_msec(t0, t1);
printf("Code executed in %f milliseconds.\n", elapsed);
return 0;
}
. But It's wall clock, I'm not sure that I can estimate performance by this way, besides, I need approach which will allow to measure time of each function which I choose. I've heard that there is approach to use CPU-time.
|
|
|
|
|
CodingStyle wrote: I've heard that there is approach to use CPU-time. And there is even a man page[^] for it.
|
|
|
|
|
|
Yeah. There is such approach like, count the number of ticks to estimate performance. I do not think that it's panacea.
Richard MacCutchan and Jochen Arndt also correct.
But I guess that you mean universal and independent implementation version. Look here.
|
|
|
|
|
|
This is probably what you need:
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
void test(){
int i;int s=0;
for(i=1; i<1000000; i++){s+=sin(i)/i;}
}
int main(void)
{
clock_t time[2], timediff;
float elapsed;
time[0] = clock();
f1();
time[1] = clock();
elapsed = ((float)abs(time[0] - time[1]))/CLOCKS_PER_SEC;
printf("Code executed in %f milliseconds.\n", elapsed);
return 0;
}
|
|
|
|
|
I am an innocent bystander of a discussion about how #include directive is handled in IDE.
The IDE in question uses proprietary file "main" name extension (still a text file) and processes #include <header.h> and #include "local_header.h" in that file just fine.
However, when the local_header.h file has <b>another #include <header_1.h></b> in it the compiler "does not see that". That is basically what people who "knows / developed" the IDE are saying.
Including another local file in first local file such as #include "local_header_1.h" is "seen / processed " by IDE.
I was under the impression that #include <file.h > tells the OS to find the file "anywhere" and #include "file.h" tells the OS to search only current / parent directory.
So why is IDE (gcc) getting into the act?
|
|
|
|
|
#include <file>
This variant is used for system header files. It searches for a file named file in a standard list of system directories.
#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>.
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html[^]
|
|
|
|
|
FTFY
Chris Losinger wrote: This variant is used for system or library header files.
|
|
|
|
|
Vaclav_Sal wrote: However, when the local_header.h file has <b>another #include <header_1.h></b> in it the compiler "does not see that". That is wrong. The compiler (or more precise: the preprocessor part) will process such includes.
However, an IDE may do other things with your files before they are passed to the compiler. But GCC is the Gnu Compiler Collection (a collection of command line tools) and not an IDE.
|
|
|
|