ericmcg@pnet91.cts.com (Eric Mcgillicuddy) (06/12/91)
Has anyone had trouble declaring a void function? The lexical analyser tells me that it was expecting a "(" as the first character after the close bracket of the parameter list. i.e. void foo () { ^ "(" expected or void foo ( int myparms) ; ^ "(" expected (yes I know the code is wrong) This is is perturbing because the manual states that a void function is more efficient since returning a parameter adds more overhead code. Declaring the same functions as int solves the problem, but I am concerned with efficiency and legibility (why type a function that doesn't return anything? Wouldn't optimizers kill a function like this?) UUCP: bkj386!pnet91!ericmcg INET: ericmcg@pnet91.cts.com
toddpw@nntp-server.caltech.edu (Todd P. Whitesel) (06/12/91)
ericmcg@pnet91.cts.com (Eric Mcgillicuddy) writes: >void foo () >{ >^ "(" expected void foo (void) { ... works for me. >void foo ( int myparms) ; > ^ "(" expected (yes I know the code is wrong) I'm not sure what the problem is here. Put a {} before the semicolon and see if it takes it. Todd Whitesel toddpw @ tybalt.caltech.edu
bkahn@spud.webo.dg.com (Bruce Kahn) (06/12/91)
In article <841@generic.UUCP>, ericmcg@pnet91.cts.com (Eric Mcgillicuddy) writes: |> Has anyone had trouble declaring a void function? The lexical analyser tells |> me that it was expecting a "(" as the first character after the close bracket |> of the parameter list. i.e. |> |> void foo () |> { |> ^ "(" expected |> Try using (void)... |> or |> |> void foo ( int myparms) ; |> ^ "(" expected (yes I know the code is wrong) |> I have a large project w/lots of void functions (w/and w/o parameters) and Ive yet to have a problem under Orca C 1.2. Then again I do prototype my functions at the top of the file. Have you tried prototyping the functions?? Bruce -- Bruce <I-wont-give-my-middle-initial> Kahn Phone (508) 870-6488 NSDD / OpenLAN Internet bkahn@archive.webo.dg.com Data General Corporation, Westboro MA USA FAX (508) 898-4212 Standard disclaimers still apply, even where prohibited by law...
gwyn@smoke.brl.mil (Doug Gwyn) (06/13/91)
In article <841@generic.UUCP> ericmcg@pnet91.cts.com (Eric Mcgillicuddy) writes: >Has anyone had trouble declaring a void function? No. Check whatever precedes the function you're having trouble with, for example an #include file. Often the preceding declaration has a problem that is not reported until parsing of the function begins.