Int main() not issuing warning with no return statement

Does anyone know why Visual C++ (2010, in my case), doesn't issue a C4715 waning (not all control paths return a value) for the main() function?
If you do this:
#include <iostream>
using namespace std;
int main()
cout << "Testing.\n";
you get no warnings. If you add the following (taken from
MSDN):
int func1( int i )
if( i )
return 3; // C4715 warning, nothing returned if i == 0
You get the warning on func1.
Is there a way to turn on the warning for main()?
Thanks.
Tom

In case a return value is not defined by the programmer, an implicit return
0; at the end of the main() function
is inserted by the compiler; this behavior is required by the C++ standard. (wiki)
You may want to read about it in the
standard, section 3.6.1.5 Main function.

Similar Messages

  • Help with a return statement please!

    hey, just hoping somone can help me with this return statement
    i have to add a method called "specialReport" this method takes a year as it's parameter. if the parameter is not a year between 1930 and 1969 inclusive it displays an error message, "not a valid year"
    if the parameter is a valid year, then it compares the parameter with the year field. if they are the same, and is the movie has been rented at least five times, the method will display the message "a good year for movies" if the years are different or the movie has NOT been rented at least five times, the method displays the message "try a different year"
    btw, the Year field is : yearReleased
    all help is very much appreciated!

    public void specialReport(int year){
       //add functionality to process here
       return;
    }

  • JTextArea will not display string with carriage return

    Hello,
    I am trying to display an XML file which i have converted into a string in a JTextArea to no avail. Any ideas how i can display the string in the JTextArea including the carriage return such that it still displays in the correct format?
    Your pointers and suggestions will be much appreciated.

    Antananarivo wrote:
    Hello,
    I am trying to display an XML file which i have converted into a string in a JTextArea to no avail. Any ideas how i can display the string in the JTextArea including the carriage return such that it still displays in the correct format?
    Your pointers and suggestions will be much appreciated.You haven't done the conversion properly.
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.WindowConstants;
    public class XMLTextArea {
        public static void main(String[] args) throws IOException {
            File f = new File("someFile.xml");
            BufferedReader br = new BufferedReader(new FileReader(f));
            StringBuilder sb = new StringBuilder();
            String nextLine = "";
            while((nextLine = br.readLine()) != null) {
                sb.append(nextLine).append("\n");
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.add(new JScrollPane(new JTextArea(sb.toString())));
            frame.setSize(400,300);
            frame.setVisible(true);
    }

  • Sync is not syncing anything with iPad, yet states sync completed successfully

    This just recently happend.
    I was tyring to sync a couple new movies to the iPad, but they would not sync over. I tried setting to sync all movies, sync only those checked, or sync those in a specific playlist. None of these changes made any difference. I thought I would try to remove a few of the videos just in case it was a weird space issue, and noticed I could not remove the videos from my iPad by removing the check mark from the viedo (I also made sure Automatically include all was not checked, nor include movies from playlists). When that didn't work, I unchecked Sync Movies to remove them all. The Capacity bar showed the video allocation went from 5.7GB to .21GB. I syncd and it completed.
    But when I checked on the iPad, ALL the videos are still there!
    I tried to only sync 1 video, Update to the latest iOS version, unchecked to syn Movies, TV Shows, Podcasts, etc, all to no avail. Even with Movies, TV Shows, and Pocdcast sync options turned off, it will not remove any of that content on my iPad, nor allow me to add new content, even though the sync states it completed properly. The more I dig through this, the more items I find not syncing. I just tried to sync a couple new apps, and they show as being on the iPad in the iTunes view, yet they are not on the iPad.
    I tried rebooting, turning off and on all syncing, updating to latest 4.3.2,etc, all to no avail. Basically, the iPad is stuck in a frozen state with regard to syncing, the views in iTunes do not match what is on the iPad, yet all attempts at syncing complete normally.
    My last resort will be to restore it to factory settings, and start with a new fresh sync if we can't figure out whats happening.
    Appreciate any help.
    Stephen

    I've found the issue. Its due to the fact I've used a I Phone Config Utility to install iMovie on the first gen iPad. I've removed it and it is now syncing as it should. I'll have to reinstall iMovie again when I need it in the future.

  • Return statement issue

    I am trying to get my jdbc method (with boolean data type) to compile but I get compile error. I seem to have a problem with my return statement:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class UserDB
        public static boolean isMatch(String lastname) throws SQLException
             try
              Class.forName("org.gjt.mm.mysql.Driver");
            String dbURL = "jdbc:mysql://localhost/dbhere";
            String username = "namehere";
            String password = "passwordhere";
            Connection connection = DriverManager.getConnection(dbURL, username, password);
             Statement stmt = connection.createStatement();
            ResultSet results = stmt.executeQuery("SELECT lastname from user where lastname = '" + lastname + "'");
             boolean myhit = results.next();
              results.close();
              stmt.close();
             return myhit;
            catch(ClassNotFoundException e)
                System.out.println("Database driver not found.");
            catch(SQLException e)
                System.out.println("Error opening the db connection: " + e.getMessage());
    }Error message:
    prompt>javac UserDB.java
    UserDB.java:34: missing return statement
         ^
    1 errorPlease advise what I am doing wrong??

    Or rewrite your code like this:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class UserDB
       public static boolean isMatch(String lastname) throws SQLException
          boolean myhit = false;
          Connection connection = null;
          Statement stmt = null;
          ResultSet results = null;
          try
                Class.forName("com.mysql.jdbc.Driver");
             String dbURL = "jdbc:mysql://localhost/dbhere";
             String username = "namehere";
             String password = "passwordhere";
             connection = DriverManager.getConnection(dbURL, username, password);
             stmt = connection.createStatement();
             results = stmt.executeQuery("SELECT lastname from user where lastname = '" + lastname + "'");
             myhit = results.next();
          catch(Exception e)
               e.printStackTrace();
          finally
                close(results);
                close(stmt);
                close(conn);
          return myhit;
       public static void close(ResultSet rs)
           try
              if (rs != null)
                 rs.close();
           catch (Exception e)
                 e.printStackTrace();
       public static void close(Statement stmt)
           try
              if (stmt != null)
                 stmt.close();
           catch (Exception e)
                 e.printStackTrace();
       public static void close(Connection conn)
           try
              if (conn != null)
                 conn.close();
           catch (Exception e)
                 e.printStackTrace();
    }%

  • Return statements

    I have a project due that is a modifcation of a pervious project. It is a lottery game that will produce 104 sets of 6 unique numbers. I have a working version but am now trying to make it OO. I am to have 3 classes a main class, checkUser that implements CheckUserInterface, and getNumbers. I have figured most of it out but I need to return a boolean from the CheckUser class to the main class. I have the return statement in the checkUser class but am unable to refrence the boolean in main. I have named the boolean errors. When I try to refrence errors the complier says unable to resolve symbol. If any can give ant insight it would be greatly appreciated!! ;0) kristin

    Prolly need to post the code.
    Between
    [code]
    Program here
    [/code]
    tags, please.

  • Dynamic select list with display,return val & join condition issue.

    hello,
    I am having a dynamic select list with display, return value
    say for example my select statement is
    select distinct dname d, deptno r
    from dept dt
    right join emp e on (e.deptno=dt.deptno)
    where (condition)
    when i tried this query for my select list, it is not working. It saying that
    " LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query. "
    I am not able to understand the problem. Can anyone help me out with this issue?
    thanks.

    Shouldn't your join have dept as the driving table?
    select distinct dname d, deptno r
    from dept dt
    right join emp e on (dt.deptno = e.deptno)
    where (condition)
    Or using older Oracle standard join
    select distinct dname d, deptno r
    from dept dt, emp e
    where (dt.deptno (+) = e.deptno) AND (OTHER WHERE condition)
    OR
    (Since a right join is just getting the values from the driving table that are NOT in the associated table)
    select distinct dname d, deptno r
    from dept dt
    WHERE dt deptno NOT IN (SELECT deptno FROM emp) AND (OTHER where condition)
    Thank you,
    Tony Miller
    Webster, TX

  • Warning message not issued

    Hi,
    I have a proble with validation.
    All warning or Informative messages are not issued using posting transactions like FB01.
    Release is 4.6C.
    We wait for your replay.
    Thanks
    Stefania

    Hi,
    The only conclusion I might think about is that your validation is not working. Put a trace on it (simulation), post a document and check that the conditions are met.
    Regards,
    Eli

  • Have tried to install icloud 4.0 for windows and again it does not allow syncing with outlook 2013 calendar and contact using windows 8.1 and IOS 8.02 (unexpected error)? I thought itunes 12.0 and icloud 4.0 would solve issue but still same result.

    I have tried to install icloud 4.0 for windows and again is does not allow syncing with outlook 2013 calendar and contact, using windows 8.1 and IOS 8.02 (get - unexpected error)?

    Having same issues. had been syncing every few days with outlook 2007 contacts and calendar but since updated to 4.0.2 and latest itunes I get an error that it is unable to sync. I can't seem to find any solution.

  • 6085 video issue -- Video not in sync with sound

    I have a Nokia 6085.  Not the best phone, I know, but it's cheap.  Anyway, I can convert video files to compatible MP4 or 3GP just fine.  My phone will play them just fine, up to a point.  After about a minute, the video starts lagging behind the sound more and more.  I've done some research on this forum, but not come up with a single straight answer.  I cannot use SmartMovie or other players, as the Nokia 6085 runs in the J2ME environment.  I've tried to update my phone, but Nokia's software says there are no updates for my phone.  I've used files I've converted myself using various bitrates, codecs, etc. I've found in various places on this forum.  I've used videos converted by others that apparently work on their devices.  No difference.  Any idea on how I can fix this?  Thanks in advance.
    Solved!
    Go to Solution.

    All right.  After much experimentation with SUPER and some researching through Google, I managed to fix my issue.  Everyone else who had this issue merely said, "Issue fixed."  I'll post my results in case anyone else has this issue:
    Container: 3gp (Nokia/NEC/Siemens)
    Output Video Codec: H.263
    Output Audio Codec: AAC LC
    Video Size: 176x144
    Frame/Sec: 12
    Video Bitrate: 144 kbps
    Hi Quality checked
    Top quality checked
    Audio sample: 44100
    2 Channels
    Audio Bitrate: 64 kbps
    Hope this helps someone. 

  • Issue is with OpenGL. System Info it allows Normal Mode but does not allow Advanced Mode.

    Problems with Repousse 3D feature in Photoshop CS5 Extended  
    I am trying to use the Repousse 3D feature in Photoshop CS5 Extended and have been unable to figure how I can get it to be an option using text. Can you explain how I do this, please?
    I have also tried rasterizing the text first and that does not work. I have tried placing the image and them loading the selection and I still do not have the option of Repousse.
    I believe the issue is with my OpenGL. In the System Info it allows Normal Mode but does not allow Advanced Mode. I spoke with the "Geek Squad" who advised that this is not an issue with my Mac but has something to do with the software.
    Can someone please help me fix this?  Thanks.

    If you really want help you may have to provide relevant information about your OS, GPU, its VRAM …

  • My photos are not printing right with adobe manages color but works when i use printer manages color. never had any issues untill a week ago.

    my photos are not printing right with adobe manages color but works when i use printer manages color. never had any issues untill a week ago.

    We use CS6, yes we calibrate using x-rite. I have always had adobe manage colors when printing. This problem just occurred, all my settings are the same as they have been for years. The only thing we did lately is do an update to CS6. We thought it might be our printer but when we use the printer manages color it works fine, The problem with adobe manages color is it is not blending the light highlights like on top of the cheeks with the colors around the cheeks  and its putting a faint red between the two it just does not have a smooth transition. I printed a photo that I had printed 4 months ago with no issue, and this time it had the issue that I am dealing with now. Somehow the photo shop manages color is not getting the right info to my printer.  
    I set paper type
    set quality
    no color adjustment
    set my profile
    Teri

  • Keyboard layout issue only with Windows 7, not Windows 8

    Hello,
    I have a strange behaviour with Remote Desktop on Windows 7. I have a RDS 2012R2 deployment, with TS Gateways, broker and remote desktop collection. I have published a RemoteApp.
    My issue is with the keyboard layout send by the client. My server is in English - Swiss French keyboard.
    With my Windows 8 client, keyboard in "French", the keyboard used in my RemoteApp is correctly set to "French"
    With my Windows 7 client, keyboard in "French", the keyboard used in my RemoteApp is set to "Swiss - French". This is not the correct layout.
    Why under Windows 7 the keyboard layout is not send correctly ? 

    Hi Sebastien,
    Initially please use latest RDP version 8.1 for windows 7 and check the result. 
    If you want the session to use the default keyboard layout stored in the user profile instead of the layout provided by the Remote desktop Server client after the user logs on to the Remote desktop Server computer, you can set the IgnoreRemoteKeyboardLayout
    registry value to 1. After users first connect to the Remote desktop Server computer, configure the default keyboard layout and input language that you want, and then log off. All later user logons will use the default keyboard layout and input language from
    the profile.
    To do so, please perform the following steps: 
    1. On the remote desktop server, click Start, click Run, type regedit, and then click OK.
    2. Locate and then click the following registry subkey:
     HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
    3. On the Edit menu, click Add Value, and then add the following registry information:
     Value name: IgnoreRemoteKeyboardLayout
    Data type: REG_DWORD
    Value data: 1
    4. Quit Registry Editor.
    After you first connect to the Remote desktop Server computer, configure the default keyboard layout and input language that you want, and then log off. All later user logons will use the default keyboard layout and input language from the profile.
    Hope it helps!
    Thanks.
    Dharmesh Solanki
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Reoccurring warning, literally every 20 seconds: "This cable or accessory is not certified and may not work reliably with this iPhone." I am only using Apple devices. How can I eliminate the warning?

    Please help me eliminate this repeating warning message on my iPhone 5. It occurs several times a minute. I am only using Apple devices, so the warning is in error.  "This cable or accessory is not certified and may not work reliably with this iPhone."

    The cable may be damaged. Try another cable.
    Make sure it properly connected at both ends.

  • I just loaded some July pictures into my PC iCloud photos upload folder, but I do not see them with my iPad. Are they not shared because they are past the 30 day window, or is there a different issue?

    I just loaded some July pictures into my PC iCloud photos upload folder, but I do not see them with my iPad. Are they not shared because they are past the 30 day window, or is there a different issue?

    Generally I would not use Facebook for sharing any photos, it compresses the photos substantially, and when you have shadows and dark colours you get visible "bands" where there should be subtle gradients, ie at sunsets and sunrises.
    It sounds like you are using two methods to upload to Facebook:
    1. Sharing from within Aperture, which basically syncs Facebook with your Aperture album, so any changes made at either end gets synced, hence the deletions from Albums, although the original file should still be in your library, just removed rom the album. It is like a playlist in iTunes.
    2. Exporting pics and uploading to Facebook from the browser.
    I am not sure how method 1 gets compressed, but I know that uploading hi-res jpegs to Facebook using method 2 results in poor quality images.
    I wouldn't even bother comparing option 1 or 2, and they will both be poor images once you view them on Facebook, as opposed to viewing uploaded images on proper image sharing / hosting sites.
    Your problem is not with Aperture, it is using Facebook for showing your work.
    If you export pics form Aperture at high res jpegs or TIFFs your images will be fine.
    If you insist to use Facebook as your way to share your work, then your workflow should be this:
    1. Right click images you want to share.
    2. Select Export version.
    3. Export as 100% size and ensure the export settings are set at 100% quality.
    4. Upload this pic into Facebook.
    This will get you the best image size and resolution on Facebook.
    See how you go.

Maybe you are looking for