Wednesday, January 3, 2018

car hood won't open

understand the problem

Yesterday was extremely cold, all day below -5 C. Then my car battery failed. When I tried to open the hood to give it a jump, the hood latch release failed.
This seems a simple mechanical problem. The latch was cleverly designed. After one evening’s study, I had a clear understanding of the problem. And it is very interesting and deserves a blog post.
There are actually 2 latches:
Each latch has its own spring. You can see how the Primary latch works by the following 2 short videos:
What to do if you have a Stuck Hood Latch or hood won’t open: https://youtu.be/mCQCatoG9Rc?t=30s
How to fix a hood latch that wont close || 1997 Chevy Lumina:https://youtu.be/z6CSHeuH-oE?t=8m7s
Or
All you need is a long stick to push the metal along the direction of latch release cable:
Hooray!

Everything is well explained in this awesome video

What if your car’s Hood won’t Open?: https://www.youtube.com/watch?v=xMrjwUfdiiE

Buy parts

back up plan, AAA

$52 per year, 5 miles of towing: https://ok.aaa.com/non-member
promo code: 52WBOS
aaa.com/stop

gcc and make

refresh C grammar

check C compiler:
gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple’s website and follow the simple installation instructions. Once you have Xcode setup, you will be able to use GNU compiler for C/C++.
#include <stdio.h>
int main(int argc, char** argv) {
    printf("argument count: %d \n",argc);
    for (int i= 0; i< argc; i++){
        printf("argument vector %d is: %s.\n ", i,argv[i]);
    }
    printf("Hello, World!\n");
    return 0;
}
argv and argc are how command line arguments are passed to main() in C and C++.
argc will be the number of strings pointed to by argv. This will (in practice) be 1 plus the number of arguments, as virtually all implementations will prepend the name of the program to the array.
The variables are named argc (argument count) and argv (argument vector) by convention, but they can be given any valid identifier: int main(int num_args, char** arg_strings) is equally valid.
When you output, always define the format you want.
Compile:
$ gcc hello.c  # default output file is a.out
$ gcc -o hello hello.c # define output file as hello
$ ./a.out
Hello, World!
Codes:
#include <stdio.h>
int main() {
   printf("Storage size for int : %d \n", sizeof(int)); //4, the exact size of a type/variable depends on a specific platform
   return 0;
}

Make grammar

why makefile?
gcc main.cpp hello.cpp factorial.cpp -o hello
This command generates hello binary. In this example, we have only four files and we know the sequence of the function calls. Hence, it is feasible to type the above command and prepare a final binary. However, for a large project where we have thousands of source code files, it becomes difficult to maintain the binary builds.
To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program and provides commands for updating each file.
It would be tricky to write a grammar for make, since the grammar is extremely context-dependent.
Names of these variables originate from names of the corresponding tools. Usually, the meaning of these abbreviations is the following:
  • CC stands for “C compiler” (in GCC abbreviation it is also treated as “compiler collection”).
  • LD is a linker (comes from “link editor” or from “loader”).
These are also commonly used in makefiles (see Implicit variables chapter of GNU Make manual):
  • CPP stands for “C preprocessor”
  • CXX is a C++ compiler
  • AS is an assembly language compiler
  • AR is an archive-maintaining program

difference between g++ and gcc

GCC: GNU Compiler Collection, Referrers to all the different languages that are supported by the GNU compiler.
gcc: GNU C Compiler
g++: GNU C++ Compiler
The main differences:
gcc will compile: .c/.cpp files as C and C++ respectively.

g++ will compile: .c/.cpp files but they will all be treated as C++ files.

Also if you use g++ to link the object files it automatically links in the std C++ libraries (gcc does not do this).

gcc compiling C files has less predefined macros.

gcc compiling .cpp and g++ compiling *.c/.cpp files has a few extra macros.