Author Topic: Implicit Declaration of Function - HELP!  (Read 779 times)

Offline biscuit_5

  • Single posting newcomer
  • *
  • Posts: 3
Implicit Declaration of Function - HELP!
« on: May 28, 2019, 08:32:43 pm »
Hi Guys,

I literally copied the code exactly as you see in the YouTube tutorial below and I get "Implicit declaration of function". However, the teacher in the video is not getting an error. He is using CodeBlocks as well. Does anyone know why it might not be working? I am listing the code exactly below for your reference as well. The only thing I can think of is that I am using a mac, but I followed the installation instructions perfectly. I also did not have any issues with any other codes until now.

https://youtu.be/KJgsSFOSQv0?t=6035

#include <stdio.h>
#include <stdlib.h>

int main()
{

    sayHi();
    return 0;
}

void sayHi() {
    printf("Hello User");
}

Offline sodev

  • Regular
  • ***
  • Posts: 315
Re: Implicit Declaration of Function - HELP!
« Reply #1 on: May 28, 2019, 11:13:37 pm »
This is not your how-do-i-code forum nor your youtube-does-not-work-forum. Your question is a general programming question and off topic for this forum.

I doubt you copied the code exactly, because ... order does matter. You cannot call anything before it has been declared.

Offline biscuit_5

  • Single posting newcomer
  • *
  • Posts: 3
Re: Implicit Declaration of Function - HELP!
« Reply #2 on: May 29, 2019, 01:09:28 am »
How is it a "how-to code" question and not a code blocks question? The code is exact and does not work for me. Yet it does for someone else using code blocks. If you actually read the code and looked at the video as a reference instead of being a prick, you would realize that. If you aren't interested in helping, don't respond. Act as you should in public. I know you wouldn't be that condescending to me in person. 

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6613
    • My Best Post
Re: Implicit Declaration of Function - HELP!
« Reply #3 on: May 29, 2019, 01:31:59 am »
How is it a "how-to code" question and not a code blocks question? The code is exact and does not work for me. Yet it does for someone else using code blocks. If you actually read the code and looked at the video as a reference instead of being a prick, you would realize that. If you aren't interested in helping, don't respond. Act as you should in public. I know you wouldn't be that condescending to me in person.

PLEASE read the rules before you are banned!http://forums.codeblocks.org/index.php/topic,9996.0.html
Also, read this FAQ
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6613
    • My Best Post
Re: Implicit Declaration of Function - HELP!
« Reply #4 on: May 29, 2019, 01:49:08 am »
I suggest you learn the difference between a warning and a error!

Code: [Select]
-------------- Clean: Debug in test (compiler: GNU GCC Compiler)---------------

Cleaned "test - Debug"

-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------

x86_64-w64-mingw32-gcc.exe -Wall -g  -c C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c -o obj\Debug\main.o
C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c: In function 'main':
C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c:7:5: warning: implicit declaration of function 'sayHi' [-Wimplicit-function-declaration]
     sayHi();
     ^~~~~
C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c: At top level:
C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c:11:6: warning: conflicting types for 'sayHi'
 void sayHi() {
      ^~~~~
C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\main.c:7:5: note: previous implicit declaration of 'sayHi' was here
     sayHi();
     ^~~~~
x86_64-w64-mingw32-g++.exe  -o bin\Debug\test.exe obj\Debug\main.o   
Output file is bin\Debug\test.exe with size 316.92 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 2 warning(s) (0 minute(s), 0 second(s))
 

-------------- Run: Debug in test (compiler: GNU GCC Compiler)---------------

Checking for existence: C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\bin\Debug\test.exe
Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\bin\Debug\test.exe"  (in C:\Users\stahta01\devel\open_source_code\no_version_control\test\test\.)
Process terminated with status 0 (0 minute(s), 2 second(s))

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline biscuit_5

  • Single posting newcomer
  • *
  • Posts: 3
Re: Implicit Declaration of Function - HELP!
« Reply #5 on: May 29, 2019, 02:49:18 am »
Oh no! Banned!!? For asking for help regarding a Code Blocks issue!? Please ban me for that. That would be hilarious. The forum is called "Help". This is clearly not just a coding issue if it executes for another individual without any warning or error, using the same software.

You guys complain a lot. You must be unhappy. If you were so knowledgable, you could answer the question and politely redirect me for the future. But I'm sure you two jump at the opportunity to be condescending pricks because you are too cowardly to do such a thing in public.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6613
    • My Best Post
Re: Implicit Declaration of Function - HELP!
« Reply #6 on: May 29, 2019, 05:50:31 am »
Oh no! Banned!!? For asking for help regarding a Code Blocks issue!? Please ban me for that. That would be hilarious. The forum is called "Help". This is clearly not just a coding issue if it executes for another individual without any warning or error, using the same software.

You guys complain a lot. You must be unhappy. If you were so knowledgable, you could answer the question and politely redirect me for the future. But I'm sure you two jump at the opportunity to be condescending pricks because you are too cowardly to do such a thing in public.

You sir, have no future in programming; Wonder if you will make it to 25 posts before you are banned.

http://www.catb.org/~esr/faqs/smart-questions.html#forum

Edit: Top Google result: https://stackoverflow.com/questions/32703675/implicit-declaration-of-function-enterchar-wimplicit-function?rq=1

NOTE: The above are hyperlinks! I suggest you learn to use search engines like Google; but, you seem to be unable to learn or you had no idea what hyper links are.

Tim S.

 
« Last Edit: May 29, 2019, 05:59:44 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline zdena

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Implicit Declaration of Function - HELP!
« Reply #7 on: May 29, 2019, 07:45:05 am »
Dear biscuit_5,
don't feel so humiliated. Try to read all this C::B forum and you will see that the boys answered tens, hundreds or even thousands of questions.

I'm pretty sure that they like interesting questions about C::B. But they cannot teach anybody how to program. Your error (really error? or warning?) is so common (I also got it a lot of times) that it could be boring to explaint it again and again. Try to empathize.

BTW did you really read the forum rules and FAQ? Or wiki?

NOTE: sodev answered your problem in the first reply.
Windows 10 64b
Arduino 1.8.5 with (modified) Arduino Builder 1.4.5 through (modified) C::B 17.12 32b
Occasional C(C++) hobbyist almost only for Arduino.
Czechia - please pardon my English

Offline sodev

  • Regular
  • ***
  • Posts: 315
Re: Implicit Declaration of Function - HELP!
« Reply #8 on: May 29, 2019, 10:24:14 am »
I did, but i was wrong... in one point... you really copied the code exactly. And stahta01 might be wrong too. Why is that so? Because you hit one of these total obscure c features.

The feature you are using there was invented 30 years ago but was so bad that the c standards committee said it should not be used and removed it 20 years ago. Why is it working for the dude in the video? Because he is compiling the code in c89 mode. Why does stahta01 get warnings and think you dont know the difference warning and error? Because he is compiling in c99 mode and gets warnings about it. Why doesnt it work for you? I dont know because you didnt provide enough information. You either compile in c99 mode and get warnings or compile in any c++ mode and get errors.

And how is that related to CodeBlocks? Nothing it all! This is a question about c language features and compilers implementing them. CodeBlocks isnt part of the c standards committee nor a compiler, it is basically a nice text editor that can launch many compilers. Unless one of these things doesnt work, it is not a CodeBlocks problem and therefor not the place to be asked here, the poor people here have enough to do to take care about CodeBlocks issues, they cant help with others topics.

But congratulations, you found a dude on YouTube who is using languages features that should not be used for 20 years now and he is proposing these to people who start programming today. Really, this guy knows pretty much nothing about programming, only how to make videos and earn money from ads. You really should not watch videos on YouTube to learn anything, they do more harm than good. This is like you try to build spaceships by watching Star Wars.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6613
    • My Best Post
Re: Implicit Declaration of Function - HELP!
« Reply #9 on: May 29, 2019, 10:59:41 am »
And, since I posted how to report the problem correctly and he failed to do so. We likely will never know his real problem. But, I would guess that he has not read either the rules or the FAQs I linked.

Tim S.
« Last Edit: May 29, 2019, 11:05:37 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org