Questions tagged [implicit-declaration]
61 questions
29
votes
4 answers
Why can't I declare a constant using var in C#?
this:
const int a = 5;
compiles just fine, whereas
const var a = 5;
doesn't... while:
var a = 5;
compiles just as well as this:
int a = 5;
why?

bevacqua
- 47,502
- 56
- 171
- 285
19
votes
2 answers
C: Implicit declaration of function
I am working on an assignment in which we are developing our own RPC client. Upon compiling my server portion, I receive warnings for the following:
implicit declaration of function 'read'
implicit declaration of function 'write'
I understand that…

kubiej21
- 700
- 4
- 14
- 29
17
votes
2 answers
Why is the move constructor neither declared nor deleted with clang?
Consider the following classes.
struct with_copy {
with_copy() = default;
with_copy(with_copy const&) {}
with_copy& operator=(with_copy const&) { return *this; }
};
struct foo {
with_copy c;
std::unique_ptr p;
};
Does…

R. Martinho Fernandes
- 228,013
- 71
- 433
- 510
17
votes
5 answers
Why does/did C allow implicit function and typeless variable declarations?
Why is it sensible for a language to allow implicit declarations of functions and typeless variables? I get that C is old, but allowing to omit declarations and default to int() (or int in case of variables) doesn't seem so sane to me, even back…

bitmask
- 32,434
- 14
- 99
- 159
7
votes
2 answers
Does the standard allow an implicit virtual destructor not being implicitly defined when no instances of its class are created?
While thinking about this question, I stumbled upon something else I don't understand.
Standard says...
[class.dtor]/4
If a class has no user-declared destructor, a destructor is implicitly declared as defaulted. An implicitly-declared destructor…

Mark
- 1,016
- 6
- 10
6
votes
6 answers
without including
below given program is working without including ? Why does this work?
int main()
{
printf("integra");
return 0;
}

venkat
- 157
- 2
- 5
6
votes
1 answer
Header for scanf_s function
While answering this question I compiled the code on Ideone and got this error
implicit declaration of function ‘scanf_s’ [-Wimplicit-function-declaration]
Isn't stdio.h is the header for scanf_s?

haccks
- 104,019
- 25
- 176
- 264
5
votes
1 answer
Implicit declaration in C
Does the following program invoke Undefined Behaviour in C?
int main()
{
printf("Printf asking: Where is my declaration ?");
}
In the above program there is an implicit declaration of printf(), so is the above code fully standard compliant or…

Prasoon Saurav
- 91,295
- 49
- 239
- 345
5
votes
2 answers
Warning: implicit declaration of function — why does my code work anyway?
I have gone through the following threads:
warning: implicit declaration of function
Implicit Declaration of Function in C UNIX
Possibly my issue is linked. But while they offer the solution that the function prototype should be declared before…

Coder
- 1,415
- 2
- 23
- 49
4
votes
4 answers
Implicit function declarations and linkage
Recently I've learnt about implicit function declarations in C. The main idea is clear but I have some troubles with understanding of the linkage process in this case.
Consider the following code ( file a.c):
#include
int main() {
…

Edgar Rokjān
- 17,245
- 4
- 40
- 67
4
votes
2 answers
Does an explicit move ctor eliminate implicit copy ctor?
I read in the accepted answer here that:
[a] copy constructor and copy assignment operator won't be generated for a class that explicitly declares a move constructor or move assignment operator
I do notice (g++ 4.7.2) that if you define a move…

CodeClown42
- 11,194
- 1
- 32
- 67
3
votes
3 answers
Implicit declaration of functions regardless of header include and ifndef
I have the well-known errors :
implicit declaration of function 'STLINKReadSytemCalls' [-Wimplicit-function-declaration]
implicit declaration of function 'printf' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in…

Badda
- 1,329
- 2
- 15
- 40
3
votes
0 answers
implicit declaration of function when compiling kernel module
I am new to working in kernel space, so I hope someone can help me with the issue I am having.
I have seen a lot of questions related to implicit declaration of function for userspace c/c++ programs, but I think the issue I am having may be…

user2884074
- 93
- 2
- 7
3
votes
4 answers
Alternative of struct tm
Does there exist any other alternative data structure instead of struct tm (having same memory allocated as this structure) ? So that I could use strftime without declaring
I am aware of the fact that relying on implicit declaration is not…

whacko__Cracko
- 6,592
- 8
- 33
- 35
3
votes
4 answers
Implicit function declarations sometimes work in C?
Can someone please explain to me why the following compiles:
int main()
{
int a = mymethod(0);
}
int mymethod(int b)
{
return b;
}
but this does not:
int main()
{
mymethod(0);
}
void mymethod(int b)
{
return;
}
I thought that…

rmp251
- 5,018
- 4
- 34
- 46