473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

A function give not error msg

Hello to all my friend!i added a function to the standard library maths.lib in turbo c++ compiler.bt i didnt declare prototype for that function and not use a header file for that.bt there is no error.How it comes possible?plz explain me.
Feb 2 '09 #1
10 1715
newb16
687 512MB
First guess is that if it returns int (or void ) and accept some float/double/int/pointers arguments, compiler passes them correctly based on their types, and if arguments in point of call are constants ( e.g. f(2) ), actual function parameters are int or double, so as compiler passes everyting ordinal expanded to int and float constants as double, everything is ok.
Feb 2 '09 #2
donbock
2,426 Expert 2GB
When you say "there is no error", do you mean (there is no compile-time error) or (there are neither compile-time nor perceptible run-time errors)?

Are you calling this new function? If not, then a missing prototype wouldn't provoke any errors.
Feb 2 '09 #3
@donbock
yeah! obviouly sir i called this function.and it was the function to calculate fact. of a number.and i dont include its header "fact.h" and it didnt give linker error.why there is no error.thanx n regards.
Feb 3 '09 #4
donbock
2,426 Expert 2GB
1. If you call an undeclared function then the C Standard mandates that the function return value is assumed to be int and the arguments are handled as in the pre-ANSI, pre-prototype, days of K&R C where the argument type is inferred from the value/variable that is passed in the function call. This is not a formal error condition so it is not surprising that you don't get a compiler error. It is disappointing that you don't get a compiler warning.

2. What is the prototype of your function? If it doesn't match the inferred K&R prototype then you can expect bugs. However, there need not be a dramatically announced run-time error -- you will just get the wrong answer.

3. You mentioned "linker error". A missing or erroneous header file can certainly cause a compiler error, but you have to put something unusual in the header to provoke a linker error.
Feb 3 '09 #5
Thanx Donbock sir! 1st there is not run time error.2ndly i read in a book that when miss prototype the error is generate by linker not compiler.plz be away my confusion.
Feb 3 '09 #6
donbock
2,426 Expert 2GB
@Kalrasoft
The linker has two major purposes. First, it resolves cross-references between object files (for example, when one file calls a function defined in another file). Second, it locates the various memory sections to specific addresses.

I don't see why a missing function prototype would interfere with either of those activities.

Can you recall the explanation in your book for why a missing prototype manifests as a linker error? It is difficult to respond to a bald statement.
Feb 3 '09 #7
JosAH
11,448 Expert 8TB
@Kalrasoft
You shouldn't do that; in your other post you wanted to mutilate the Standard library and now you're mutilating the math library; don't do that. Create your own library and also create the appropriate .h files for it.

kind regards,

Jos
Feb 3 '09 #8
Sorry for late.bt i was busy.yes i remember that book lines.these r "it is also possible to have errors during linking process.for instance,linker will issue an error message if u have not included the file stdio.h.The programm will compile correctly,bt will fail to link system library."So sir plz read these lines carefully n solve my confusion.Thanx and regards.
Feb 4 '09 #9
[quote=newb16;3459464]First guess is that if it returns int (or void ) and accept some float/double/int/pointers arguments, compiler passes them correctly based on their types, and if arguments in point of call are constants ( e.g. f(2) ), actual function parameters are int or double, so as compiler passes everyting ordinal expanded to int and float constants as double, everything is ok.

Thanx for ans.and i am using a function that give/take int type.so i think it was the reason there is not any error.
Feb 4 '09 #10
@JosAH
Thanx for advising Sir.
Feb 4 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
3
by: Piotre Ugrumov | last post by:
I have declared some function virtual, but when I call this function I have errors. In a class Simulator I have defined this: Nave *navi; The virtual function is the function modifica(). I call...
13
by: Tony Johansson | last post by:
Hello Experts! I want to create a virtual clone but I'm not sure if this is the wright way. Can somebody tell me where I have made error in the code. I get some compile error in this code also....
2
by: Jozef | last post by:
Hello, I'm trying to create a central function that runs a connection to an SQL Server database. The connection etc works, but when I try to call it, I get an error saying "Runtime-Error 91:...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
42
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
7
by: Uwe Grawert | last post by:
Hello, a C-function expects me to give a pointer to a function as parameter. i want to give this function a pointer to a member function of a class but the compiler gives me an error: void...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.