Preprocessor directives

closed account (jvqpDjzh)
I am having a small problem using these directives. I usually use them just to avoid multiple inclusions of files or for the usual routines. Now I was joking a bit with them defining something like this:
1
2
3
4
5
6
7
8
9
#ifndef CPP
#define CPP

int main()
{
return 0;
}

#endif 


When I run this trivial program, my AVG tells me that it has just found a trojan "Agent4.TAL" in the degub folder of my stupid "project".
Any ideas why this is happening?
Last edited on
1. False positive.
2. You do have trojan and your AV software detected it when it infected newly created file.

(looks like it false positive: http://stackoverflow.com/questions/7987712/why-does-avgantivirus-detect-an-executable-produced-from-dev-c-as-a-virus
http://www.cplusplus.com/forum/beginner/67634/ )
closed account (jvqpDjzh)
I have changed many things in my program and the AVG is no more detecting the trojan :)
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef CPP
#define CPP

#endif // CPP

#include <iostream>
using namespace std;

int main()
{
    return 0;
}


Ok, thank you anyway!
1) you shouldn't create include guards for cpp files
2) As you have them now, they are completely useless.
closed account (jvqpDjzh)
As you have them now, they are completely useless.
Yes, that's what I have been doing for a life :(
But we have to use them when we are talking about inclusion of multiple files, as I said, when we are talking about big projects.
But we have to use them when we are talking about inclusion of multiple files, as I said, when we are talking about big projects.
Yes, but you have to put your code between ifndef/endif, not after them.
And use them only within files which will be included (.h files). And make sure that every include guard macro has unique name.
Last edited on
closed account (jvqpDjzh)
1
2
Yes, but you have to put your code between ifndef/endif, not after them.
And use them only within files which will be included (.h files). 
I know. I have used it many times. What I have done here is just, as I mentioned, a stupid program.

And make sure that every include guard macro has unique nameYes, right, thanks.
Last edited on
The AV problem has nothing to do with #include headers or anything.

Antivirus companies are a little overzealous when reporting malware. It is a problem particularly among Delphi users -- because AV companies will tag any Delphi-produced program as dangerous, just because someone, somewhere wrote a virus with the same version of Delphi -- and the compiled executable happens to have the same embedded timestamp as said 'virus'.

Chances are the same problem is happening to you.

When that happens, wait a few minutes and try recompiling your entire program from source. That should fix the problem. If it doesn't, submit it to the AV vendors.
https://www.google.com/search?q=antivirus+false+positive+submit

Hope this helps.
closed account (jvqpDjzh)
When that happens, wait a few minutes and try recompiling your entire program from source. That should fix the problem. If it doesn't, submit it to the AV vendors.
Yes, that's exactly what I had done ;) Thank you anyway for sharing your knowledge!
Topic archived. No new replies allowed.