From owner-freebsd-questions@freebsd.org Wed Jul 4 12:30:56 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 24B22103090E for ; Wed, 4 Jul 2018 12:30:56 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: from mail-ua0-x22a.google.com (mail-ua0-x22a.google.com [IPv6:2607:f8b0:400c:c08::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB3C0772B6 for ; Wed, 4 Jul 2018 12:30:55 +0000 (UTC) (envelope-from olivares14031@gmail.com) Received: by mail-ua0-x22a.google.com with SMTP id r18-v6so3326509ual.13 for ; Wed, 04 Jul 2018 05:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rVT0DUf4Zwlbwjt9hJZ9vsja8sMd8I/QKpyIDcELH+Y=; b=QEeU9iw+cZn5v1I2t/inwtW1I3Mtwrc3plfDEpcAjlYz1GClUG/TGNyUYJhuDWTrGf Y3h6Bzka8rKUI1i2/N/LNtijF/Kfg3K5sBORtggOb+Ao2HNi89Y8Y3BanU/gd0o6ourl QOju6w4aGLm8ANTQLhC8h5/2ZU03r4ZusPTjYhpTeeuZtg9RJGp3Nxj4GwbTT52Eqkl4 enwnQi2fXYgqmJsh+NJNknTIsewZmLSUCkZsVUqXRlak93KxEMppNNinLA3BiKGbkisy 7Ylli1Dav1NQbpUYmjmEAE061ZhOPZBpMEU7SSp/s9RMIpLyn6GFlD4Lx/Y1pVSjH7sd yl/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rVT0DUf4Zwlbwjt9hJZ9vsja8sMd8I/QKpyIDcELH+Y=; b=Ab3lTifSaOQr4IOz0ZI1ik7BmCiCz04GcirLy9oQ+bQ1G75Rt27Yc2QJK6XjXboHkY h/v97JipP9+4eKE9SVJ44g87byh05VD5O1D973xvHlCmnKDjpMnaT8xSCNzFNJ6TawtL 6dCGwHel3x3u3n4O8AXhBjzp9Iq65pFiXqLKB7avuZ4zN1hoYdVn7ZIgVaSrTjGlRgTL XtqpcTU+EBLd6JWYWTZxco7C0aOi0s52u+YY7PtExeUHlx7S0n2eLc4Wdnd/zMr9PWtw 2nI8Wew7Vwa0mDpoP5+108lqGrvj8sKBXjcXWxM+N7EIr+ai8f8/F9J1Fx76nJ0ZN2DU t46Q== X-Gm-Message-State: APt69E3jzn5zjIniTzJ7LAjeJfut8Ii7G+hCsA0RVNGQYH4GaQzK3VE+ c65HvAczzUp5/ewZYYNz97m3ecYAXfS4aXm6sEI= X-Google-Smtp-Source: AAOMgpeJDJY+WXa8IedU4iHMo1Vm2i9b6TWpwdJGsknv1+vv10/HBn31ukgUQu1mXLtFUqzPl5+X8FUe7tkcz0G913c= X-Received: by 2002:a9f:3861:: with SMTP id q30-v6mr1043602uad.170.1530707454670; Wed, 04 Jul 2018 05:30:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:51c7:0:0:0:0:0 with HTTP; Wed, 4 Jul 2018 05:30:54 -0700 (PDT) In-Reply-To: References: From: Antonio Olivares Date: Wed, 4 Jul 2018 07:30:54 -0500 Message-ID: Subject: Re: Clang++ stdlib/cstdlib.h workaround To: Shane Ambler Cc: FreeBSD Questions Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 12:30:56 -0000 On Tuesday, July 3, 2018, Shane Ambler wrote: > On 04/07/2018 04:08, Antonio Olivares wrote: >> Dear kind folks, >> >> I have a cpp file that used stdlib.h and it compiled and ran successfully. >> I am trying it out with clang and it returns errors that it cannot find >> stdlib.h, I remove the stdlib.h include statement and it still complains. > > You can add -I as an argument that tells clang where to search for > header files. -L does the same for libraries. Even when you remove > it another included file may still want it. > > clang++ -I/usr/include -L/usr/lib -o myapp myfile.cpp > >> I made a copy of the c++ file and it compiles and runs correctly, but I >> removed some stuff " --- " and only output the numbers. How do I deal with >> stdlib.h requirements? >> >> The program finds numbers that are triangular and square. It fails for >> numbers that are bigger than 2147483647. > > Does that number have any significance to you? It is the largest number > that can be held by a 32bit signed integer. You can use an unsigned int > to get twice that or you can use a long long to get a 64bit integer. > > Also related is that the math library functions have several variations > that take different size arguments. > > -- > FreeBSD - the place to B...Software Developing > > Shane Ambler > > Shane, Thanks for your input. For the moment I have removed the header file #include >From the c++ program. In a for loop part, I had a set of statements to output the values where the number was a triangular and square at the same time in two lines. This was where the program was failing to compile and I was concluding incorrectly that it had to do with the stdlib.h or cstdlib.h file. #include #include using namespace std; int main() { int i; int n; int k; cout << "This program searches for numbers that\n"; cout << "are both square and triangular\n"; cout << "Up to what number do you want to search?\n\n"; cout << "Enter number: "; cin >> n; for (i=1; i